From c438756bded0b873e1d72d1f9937946f9bb7b533 Mon Sep 17 00:00:00 2001 From: wancat Date: Thu, 16 Nov 2023 21:13:18 +0800 Subject: [PATCH] feat: update CI/CD work, compose, and README --- .github/workflows/ci_cd.yml | 12 ++---------- .gitignore | 1 - README.md | 27 +++++++++++++++++++++++++++ docker-compose.prod.yml | 6 ------ docker-compose.testing.yml | 6 ------ package.json | 2 +- quests/spell/home/ancient_scroll.txt | 0 server/package.json | 2 +- 8 files changed, 31 insertions(+), 25 deletions(-) create mode 100644 quests/spell/home/ancient_scroll.txt diff --git a/.github/workflows/ci_cd.yml b/.github/workflows/ci_cd.yml index 73fbcb8..b0ce4f4 100644 --- a/.github/workflows/ci_cd.yml +++ b/.github/workflows/ci_cd.yml @@ -33,8 +33,8 @@ jobs: - name: Build Test Environment, Stage 1 run: docker-compose -f docker-compose.testing.yml build base backend app-test - - name: Build Test Environment, Stage 2 - run: docker-compose -f docker-compose.testing.yml build helloworld + - name: Build Test Quests + run: docker-compose -f docker-compose.testing.yml run --rm backend yarn build:quests - name: Run Cypress Tests env: @@ -99,14 +99,6 @@ jobs: push: true tags: docker.io/${{ secrets.DOCKERHUB_USERNAME }}/linux-odyssey:base - - name: Build quest helloworld - uses: docker/build-push-action@v2 - with: - context: . - file: ./quests/helloworld/Dockerfile - push: true - tags: docker.io/${{ secrets.DOCKERHUB_USERNAME }}/linux-odyssey:helloworld - deploy: needs: build-and-push runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 8534ca9..a389d25 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ lerna-debug.log* .bash_history .viminfo *.swp -home # Diagnostic reports (https://nodejs.org/api/report.html) report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json diff --git a/README.md b/README.md index 7f649e2..67e69df 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,33 @@ If you want to enable social login, you should have OAuth client token in a `.en docker compose --env-file .env up -d +### Build Quest Images + +In each quest folder, there is a `game.yml` file, which is the quest definition. And a optional `Dockerfile` to overwrite the base image. If you want to include additional files, put them in a `home` folder. The files in `home` will **not** be copied to the image automatically, you have to copy them in the `Dockerfile`. + + quests/ + ├── Dockerfile # Base image + ├── discover + │ └── game.yml + ├── helloworld + │ ├── Dockerfile # Overwrite the image + │ ├── game.yml + │ └── home # Include additional files + │ └── forgotten_scroll.txt + ├── read + │ └── game.yml + └── spell + ├── Dockerfile + ├── game.yml + └── home + └── ancient_scroll.txt + +To build all quests: + + yarn build:quests + +The base image is built with docker-compose, so you can use `docker compose build base` to rebuild it. Once you rebuild the base image, you have to rebuild all quests. + ## Testing Run Cypress locally, using the current development containers: diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index 5174a73..23c00ac 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -81,12 +81,6 @@ services: context: . dockerfile: ./quests/Dockerfile - helloworld: - image: lancatlin/linux-odyssey:helloworld - build: - context: . - dockerfile: quests/helloworld/Dockerfile - networks: internal: players: diff --git a/docker-compose.testing.yml b/docker-compose.testing.yml index b0c2cca..b0ff2f3 100644 --- a/docker-compose.testing.yml +++ b/docker-compose.testing.yml @@ -69,12 +69,6 @@ services: context: . dockerfile: ./quests/Dockerfile - helloworld: - image: lancatlin/linux-odyssey:helloworld - build: - context: . - dockerfile: quests/helloworld/Dockerfile - networks: internal: players: diff --git a/package.json b/package.json index 1456510..fb0741a 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "analytics": "yarn workspace analytics dev", "setup": "yarn workspace server setup", "clean": "yarn workspace server clean", - "build:image": "yarn workspace server build" + "build:quests": "yarn workspace server build:quests" }, "devDependencies": { "@vue/eslint-config-prettier": "^7.1.0", diff --git a/quests/spell/home/ancient_scroll.txt b/quests/spell/home/ancient_scroll.txt new file mode 100644 index 0000000..e69de29 diff --git a/server/package.json b/server/package.json index 0c4e5f8..f7023b8 100644 --- a/server/package.json +++ b/server/package.json @@ -9,7 +9,7 @@ "test": "yarn node --experimental-vm-modules $(yarn bin jest)", "setup": "node src/cli/setup.js", "clean": "node src/cli/clean.js", - "build": "node src/cli/build.js" + "build:quests": "node src/cli/build.js" }, "dependencies": { "@linux-odyssey/constants": "*",