Deployment¶
This page describes how the app is deployed to staging via GitLab CI/CD, Docker Compose, and Traefik.
Overview¶
- Staging runs on push to
masterordevelop. The pipeline builds the frontend and docs in CI, then deploys artifacts to the server and starts containers. - Routing is done by Traefik (external) using subdomains and HTTPS (Let’s Encrypt).
- A more detailed, server-oriented guide lives in the repo root: DEPLOYMENT.md.
Pipeline¶
Build stage¶
Two jobs run in parallel:
- build
- Image:
node:22-alpine - Runs
npm ciandnpm run build. - The frontend is built with
VITE_API_BASE_URLfrom CI variables (default:https://api.simu-game.my-game.com/api). -
Artifact:
dist/. -
build:docs
- Image:
python:3-alpine - Installs
zensicalandmkdocstrings, then runszensical build. - Artifact:
site/(Zensical’s default output).
Deploy stage¶
deploy:stage runs only after both build jobs succeed (needs: [build, build:docs]).
-
SSH setup
UsesSSH_PRIVATE_KEY(base64-decoded),DEPLOY_USER, andDEPLOY_HOSTfrom GitLab CI/CD variables. -
Copy to server
- Target directory:
/opt/game/ dist/→ frontend static filessite/→ built documentationdocs/(source),docker-compose.stage.yml,.docker/*,package*.json,tsconfig.json,zensical.toml-
src/server/andsrc/sim/for the API server build -
On the server
docker compose -f docker-compose.stage.yml pull || truedocker compose -f docker-compose.stage.yml up -d --build
So web and api images are built on the server; docs uses the pre-builtsite/via a volume.
Staging services¶
| Service | Role | Traefik rule | URL (example) |
|---|---|---|---|
| web | Nginx serving dist/ |
Host(simu-game.my-game.com) |
https://simu-game.my-game.com |
| api | Express API | Host(api.simu-game.my-game.com) |
https://api.simu-game.my-game.com |
| docs | Nginx serving site/ |
Host(docs.simu-game.my-game.com) |
https://docs.simu-game.my-game.com |
All use the external Docker network traefik and TLS via Let’s Encrypt (certresolver=letsencrypt).
Required CI/CD variables¶
Configure in GitLab: Settings → CI/CD → Variables.
| Variable | Purpose |
|---|---|
DEPLOY_HOST |
Staging server hostname or IP |
DEPLOY_USER |
SSH user |
SSH_PRIVATE_KEY |
Private key for deployment (base64-encoded; pipeline decodes it) |
VITE_API_BASE_URL |
(Optional) API base URL for the frontend build; default is set in .gitlab-ci.yml |
Changing domains or API URL¶
- Traefik / domains: Edit the
Host(...)labels indocker-compose.stage.ymland ensure DNS points to the server. - API URL for the frontend: Set the
VITE_API_BASE_URLCI variable and/or the default in.gitlab-ci.ymlvariables(must include the path, e.g.https://api.simu-game.my-game.com/api).
Troubleshooting¶
- Logs on server:
docker compose -f docker-compose.stage.yml logs -f [web|api|docs] - Force rebuild:
docker compose -f docker-compose.stage.yml up -d --build --force-recreate - API health:
curl https://api.simu-game.my-game.com/health(or your API host)
For more detail (Traefik network, manual deploy, etc.) see DEPLOYMENT.md in the project root.