From d8f8605df92fba7d3faecde802787f9a49f14007 Mon Sep 17 00:00:00 2001 From: wancat Date: Tue, 22 Aug 2023 12:11:58 +0800 Subject: [PATCH] fix: deployment + include api-docs in nginx + include quests in docker compose + update README --- README.md | 82 ++++++++++++++++------------------------ deployment/nginx.conf | 4 ++ docker-compose.build.yml | 7 ---- docker-compose.prod.yml | 8 +++- docker-compose.yml | 6 +++ 5 files changed, 48 insertions(+), 59 deletions(-) delete mode 100644 docker-compose.build.yml diff --git a/README.md b/README.md index 58467aa..63ecaaa 100644 --- a/README.md +++ b/README.md @@ -8,76 +8,58 @@ ## Installation -``` -git clone https://github.com/lancatlin/linux-odyssey.git -cd linux-odyssey -yarn install -``` + git clone https://github.com/lancatlin/linux-odyssey.git + cd linux-odyssey + yarn install -## Create database +## Developement -``` -docker compose pull -docker compose up -d db -``` - -## Server - -Source: `server/` - -``` -docker compose -f docker-compose.build.yml pull -docker compose up -d -# Open http://localhost:3000 -``` - -### Build images +Run everything (frontend, backend, db, swagger, quests): docker compose build - docker compose push + docker compose up -d -Game images: +### Deployment -``` -docker compose -f docker-compose.build.yml build -docker compose -f docker-compose.build.yml push -``` + docker compose -f docker-compose.prod.yml build + docker compose -f docker-compose.prod.yml push -## App + # Server side + docker compose -f docker-compose.prod.yml pull + docker compose -f docker-compose.prod.yml up -d + +## Standalone App (without Docker) Source: `app/` -``` -# Connect to dev server (https://odyssey.wancat.cc) -yarn app + # Connect to dev server (https://odyssey.wancat.cc) + yarn app -# Connect to localhost (http://localhost:3000) -yarn app:local -``` + # Connect to localhost (http://localhost:3000) + yarn app:local + + # Connect to anyhost + API_ENDPOINT=http://example.com yarn app:local ## Swagger -``` -docker compose up -d swagger -``` + docker compose up -d swagger Open http://localhost:8080 to open Swagger -## CLI terminal client +## CLI terminal client (Docker not required) -``` -yarn cli -Usage: client [options] [command] + yarn cli + Usage: client [options] [command] -Options: - -s, --session Session ID - -c, --create Create a new session - -h, --host Server host (default: "http://localhost:3000") - --help display help for command + Options: + -s, --session Session ID + -c, --create Create a new session + -h, --host Server host (default: "http://localhost:3000") + --help display help for command -Commands: - list List all sessions -``` + Commands: + list List all sessions connet to recent session: diff --git a/deployment/nginx.conf b/deployment/nginx.conf index 7a58af6..278bcb1 100644 --- a/deployment/nginx.conf +++ b/deployment/nginx.conf @@ -11,6 +11,10 @@ server { proxy_pass http://backend:3000; } + location /api-docs/ { + proxy_pass http://backend:3000; + } + location /socket.io/ { proxy_pass http://backend:3000; proxy_http_version 1.1; diff --git a/docker-compose.build.yml b/docker-compose.build.yml deleted file mode 100644 index 2c80ffd..0000000 --- a/docker-compose.build.yml +++ /dev/null @@ -1,7 +0,0 @@ -version: '3' -services: - helloworld: - image: lancatlin/linux-odyssey:helloworld - build: - context: . - dockerfile: quests/helloworld/Dockerfile diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index adc0808..e448dad 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -18,8 +18,6 @@ services: networks: - internal - players - ports: - - '3000:3000' volumes: - /var/run/docker.sock:/var/run/docker.sock environment: @@ -42,6 +40,12 @@ services: - MONGO_PASS=user-password - MONGO_DB=odyssey-test + helloworld: + image: lancatlin/linux-odyssey:helloworld + build: + context: . + dockerfile: quests/helloworld/Dockerfile + networks: internal: players: diff --git a/docker-compose.yml b/docker-compose.yml index 86738ef..9e15ab5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -47,6 +47,12 @@ services: environment: - SWAGGER_FILE=/tmp/swagger.yaml + helloworld: + image: lancatlin/linux-odyssey:helloworld + build: + context: . + dockerfile: quests/helloworld/Dockerfile + networks: internal: players: