Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: install food by url #254

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ So the project does not become one big monolith.

![next-orders-arch](https://github.com/next-orders/space/blob/main/.github/media/next-orders-arch.png?raw=true)

I'm currently working on first version of the website. Next year there will be a new version that will easily replace the old one as the Main API with business logic will remain the same.
I'm currently working on the first version of the website. Next year there will be a new version that will easily replace the old one as the Main API with business logic will remain the same.

Let's see what happens. Give the project a star ⭐. Offer your ideas and make commits.

Expand All @@ -35,21 +35,43 @@ Let's see what happens. Give the project a star ⭐. Offer your ideas and make c
- Website has its own backend, where API data does not break out
- Most of the code is rendered on the server: less load on the client

## 🌎 Locales

The application has [several localizations](https://github.com/next-orders/space/tree/main/apps/food/app/locales):

- English
- Russian

## 🥒 Structure

- [Food e-commerce](https://github.com/next-orders/space/tree/main/apps/food): Storefront and Command Center. Client can order delicious food.
- [NextOrders Website](https://github.com/next-orders/space/tree/main/apps/website): Documentation and SaaS

## ☕ How to deploy

You can use Docker Image:
⚠️ Warn: work in progress. Be careful with updates! Your images and DB data are at risk.

You can deploy @next-orders/food on your server (1GB+ RAM) by this:

```shell
# Connect over SSH and use with args: version, locale, your domain, your email
curl -fsSL https://nextorders.space/food/install.sh | bash -s -- "v0.6.0" "en" "test.nextorders.space" "resolve@nextorders.space"

# It will install Docker, Docker Compose and download latest docker-compose.yaml
# After, it will bring up Traefik to serve web requests, create and autoupdate SSL certificate
# Food app, DB, migrations... You are ready to check your domain!
```

Also, you can use single Docker Image to create container (you need external PostgreSQL as DB):

```shell
# use the specific version
# Use the specific version
docker pull ghcr.io/next-orders/food:v0.6.0

# Warn: you need an external PostgreSQL as DB
```

Check **.env.example** for more info about required config variables.
Check [**.env.example**](https://github.com/next-orders/space/tree/main/apps/food/.env.example) for more info about required config variables.

## 🍿 How to develop

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
food:
container_name: food
image: ghcr.io/next-orders/food:nightly
image: ghcr.io/next-orders/food:${VERSION}
ports:
- 3000:3000
restart: unless-stopped
Expand All @@ -21,7 +21,7 @@ services:

food-db-migration:
container_name: food-db-migration
image: ghcr.io/next-orders/food-db-migration:nightly
image: ghcr.io/next-orders/food-db-migration:${VERSION}
env_file:
- .env
depends_on:
Expand Down
12 changes: 9 additions & 3 deletions docker/food/install.sh → apps/website/public/food/install.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#!/bin/bash

# curl -fsSL https://nextorders.space/food/install.sh | bash -s -- "nightly" "ru" "test.nextorders.space" "resolve@nextorders.space"

# Args
NUXT_PUBLIC_LOCALE=$1 # "en" by default
DOMAIN_NAME=$2
EMAIL=$3
VERSION=$1
NUXT_PUBLIC_LOCALE=$2 # "en" by default
DOMAIN_NAME=$3
EMAIL=$4

# Env Vars
POSTGRES_USER="sushi"
Expand Down Expand Up @@ -66,12 +69,14 @@ sudo systemctl start docker
DATABASE_URL="postgres://$POSTGRES_USER:$POSTGRES_PASSWORD@food-db:5432/$POSTGRES_DB"

# Create the .env file inside the app directory
mkdir -p $APP_DIR
echo "POSTGRES_USER=$POSTGRES_USER" > "$APP_DIR/.env"
echo "POSTGRES_PASSWORD=$POSTGRES_PASSWORD" >> "$APP_DIR/.env"
echo "POSTGRES_DB=$POSTGRES_DB" >> "$APP_DIR/.env"
echo "DATABASE_URL=$DATABASE_URL" >> "$APP_DIR/.env"

# App environment variables
echo "VERSION=$VERSION" >> "$APP_DIR/.env"
echo "NUXT_PUBLIC_LOCALE=$NUXT_PUBLIC_LOCALE" >> "$APP_DIR/.env"
echo "NUXT_CHANNEL_ID=$NUXT_CHANNEL_ID" >> "$APP_DIR/.env"
echo "NUXT_SESSION_PASSWORD=$NUXT_SESSION_PASSWORD" >> "$APP_DIR/.env"
Expand All @@ -82,6 +87,7 @@ echo "EMAIL=$EMAIL" >> "$APP_DIR/.env"

# Build and run the Docker containers from the app directory
cd $APP_DIR
curl -fsSL https://nextorders.space/food/docker-compose.yaml -o docker-compose.yaml
sudo docker-compose up --build -d

# Check if Docker Compose started correctly
Expand Down