XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

feat: create Docker image, set up Docker CI (#528)

533c249e
sw5ciprl <51961935+sw5ciprl@users.noreply.github.com>
提交于

代码差异

8 个文件 +131 -31
Added .dockerignore +5 -0
@@ -0,0 +1,5 @@
1 **/.dockerignore
2 **/.git
3 Dockerfile*
4 .*
5 docker-data/
Deleted .env.example +0 -4
@@ -1,4 +0,0 @@
1 # Docker may need a .env file for the following settings:
2 DATABASE_PORT=27017
3 DATABASE_USERNAME=root
4 DATABASE_PASSWORD=database
Modified .github/workflows/build.yml +1 -1
@@ -19,4 +19,4 @@ jobs:
19 19 - run: cp config.json.example config.json
20 20 - run: echo '{"version":"","buildLabel":"","matchmakingBuildId":""}' > static/data/buildConfig.json
21 21 - run: npm run build
22 - run: npm run lint
22 - run: npm run lint
Added .github/workflows/docker.yml +25 -0
@@ -0,0 +1,25 @@
1 name: Build Docker image
2 on:
3 push:
4 branches:
5 - main
6 jobs:
7 docker:
8 runs-on: ubuntu-latest
9 steps:
10 - name: Set up Docker buildx
11 uses: docker/setup-buildx-action@v3
12 - name: Log in to container registry
13 uses: docker/login-action@v3
14 with:
15 registry: ghcr.io
16 username: ${{ github.actor }}
17 password: ${{ secrets.GITHUB_TOKEN }}
18 - name: Build and push
19 uses: docker/build-push-action@v6
20 with:
21 platforms: linux/amd64,linux/arm64
22 push: true
23 tags: |
24 ghcr.io/spaceninjaserver/spaceninjaserver:latest
25 ghcr.io/spaceninjaserver/spaceninjaserver:${{ github.sha }}
Modified .gitignore +4 -1
@@ -15,4 +15,7 @@ yarn.lock
15 15 /logs
16 16
17 17 # MongoDB VSCode extension playground scripts
18 /database_scripts
18 /database_scripts
19
20 # Default Docker directory
21 /docker-data
Modified Dockerfile +26 -3
@@ -1,5 +1,28 @@
1 FROM mongo as base
1 FROM node:18-alpine3.19
2 2
3 EXPOSE 27017
3 ENV APP_MONGODB_URL=mongodb://mongodb:27017/openWF
4 ENV APP_MY_ADDRESS=localhost
5 ENV APP_HTTP_PORT=80
6 ENV APP_HTTPS_PORT=443
7 ENV APP_AUTO_CREATE_ACCOUNT=true
8 ENV APP_SKIP_STORY_MODE_CHOICE=true
9 ENV APP_SKIP_TUTORIAL=true
10 ENV APP_SKIP_ALL_DIALOGUE=true
11 ENV APP_UNLOCK_ALL_SCANS=true
12 ENV APP_UNLOCK_ALL_MISSIONS=true
13 ENV APP_UNLOCK_ALL_QUESTS=true
14 ENV APP_COMPLETE_ALL_QUESTS=true
15 ENV APP_INFINITE_RESOURCES=true
16 ENV APP_UNLOCK_ALL_SHIP_FEATURES=true
17 ENV APP_UNLOCK_ALL_SHIP_DECORATIONS=true
18 ENV APP_UNLOCK_ALL_FLAVOUR_ITEMS=true
19 ENV APP_UNLOCK_ALL_SKINS=true
20 ENV APP_UNIVERSAL_POLARITY_EVERYWHERE=true
21 ENV APP_SPOOF_MASTERY_RANK=-1
4 22
5 CMD ["mongod"]
23 RUN apk add --no-cache bash sed wget jq
24
25 COPY . /app
26 WORKDIR /app
27
28 ENTRYPOINT ["/app/docker-entrypoint.sh"]
Modified docker-compose.yml +41 -22
@@ -1,24 +1,43 @@
1 version: "3.9"
2
3 1 services:
4 mongodb:
5 container_name: mongodb
6 image: mongodb
7 restart: always
8 build:
9 context: .
10 dockerfile: Dockerfile
11 target: base
12 environment:
13 MONGO_INITDB_ROOT_USERNAME: ${DATABASE_USERNAME}
14 MONGO_INITDB_ROOT_PASSWORD: ${DATABASE_PASSWORD}
15 ports:
16 - ${DATABASE_PORT}:${DATABASE_PORT}
17 expose:
18 - "${DATABASE_PORT}"
19 networks:
20 - docker
2 openwf:
3 # build: .
4 image: ghcr.io/spaceninjaserver/SpaceNinjaServer:latest
5 environment:
6 APP_MONGODB_URL: mongodb://openwfagent:spaceninjaserver@mongodb:27017/
21 7
22 networks:
23 docker:
24 external: true
8 # Following environment variables are set to default image values.
9 # Uncomment to edit.
10
11 # APP_MY_ADDRESS: localhost
12 # APP_HTTP_PORT: 80
13 # APP_HTTPS_PORT: 443
14 # APP_AUTO_CREATE_ACCOUNT: true
15 # APP_SKIP_STORY_MODE_CHOICE: true
16 # APP_SKIP_TUTORIAL: true
17 # APP_SKIP_ALL_DIALOGUE: true
18 # APP_UNLOCK_ALL_SCANS: true
19 # APP_UNLOCK_ALL_MISSIONS: true
20 # APP_UNLOCK_ALL_QUESTS: true
21 # APP_COMPLETE_ALL_QUESTS: true
22 # APP_INFINITE_RESOURCES: true
23 # APP_UNLOCK_ALL_SHIP_FEATURES: true
24 # APP_UNLOCK_ALL_SHIP_DECORATIONS: true
25 # APP_UNLOCK_ALL_FLAVOUR_ITEMS: true
26 # APP_UNLOCK_ALL_SKINS: true
27 # APP_UNIVERSAL_POLARITY_EVERYWHERE: true
28 # APP_SPOOF_MASTERY_RANK: -1
29 volumes:
30 - ./docker-data/static:/app/static/data
31 - ./docker-data/logs:/app/logs
32 ports:
33 - 80:80
34 - 443:443
35 depends_on:
36 - mongodb
37 mongodb:
38 image: docker.io/library/mongo:8.0.0-noble
39 environment:
40 MONGO_INITDB_ROOT_USERNAME: openwfagent
41 MONGO_INITDB_ROOT_PASSWORD: spaceninjaserver
42 volumes:
43 - ./docker-data/database:/data/db
Added docker-entrypoint.sh +29 -0
@@ -0,0 +1,29 @@
1 #!/bin/bash
2 set -e
3
4 # Set up the configuration file using environment variables.
5 echo '{
6 "logger": {
7 "files": true,
8 "level": "trace",
9 "__valid_levels": "fatal, error, warn, info, http, debug, trace"
10 }
11 }
12 ' > config.json
13
14 for config in $(env | grep "APP_")
15 do
16 var=$(echo "${config}" | tr '[:upper:]' '[:lower:]' | sed 's/app_//g' | sed -E 's/_([a-z])/\U\1/g' | sed 's/=.*//g')
17 val=$(echo "${config}" | sed 's/.*=//g')
18 jq --arg variable "$var" --arg value "$val" '.[$variable] += $value' config.json > config.tmp
19 mv config.tmp config.json
20 done
21
22 if [ ! -f "/app/static/data/buildConfig.json" ]
23 then
24 echo "buildConfig not found, refusing to start."
25 exit 1
26 fi
27
28 npm install
29 exec npm run dev