Scalable, containerized deployment for the Contest Management System (CMS).
📚 New to CMS? Check out our Step-by-Step Tutorial for a complete walkthrough!
| Path | Command | Best for |
|---|---|---|
| 1. One-stop script ⭐ | ./cms |
Everyone. Zero-arg full bootstrap, resumable |
| 2. Pre-built images | make env && make core-img ... |
Fast production deploys |
| 3. Build from source | make env && DEPLOYMENT_TYPE=src make core ... |
Custom CMS patches / air-gapped |
| 4. Raw docker compose | docker compose --profile core up -d --build |
Compose-native workflows |
All four paths share one config step (make env) and one consolidated
docker-compose.yml with service profiles
(core, admin, contest, worker, monitor).
git clone https://github.com/champyod/cms-docker.git
cd cms-docker
git submodule update --init --recursive # pulls the CMS Python source
# Linux worker hosts additionally need (once, root):
sudo ./scripts/__worker_cgroup_setup.sh # prepares isolate cgroup pathRequirements: Docker Engine + compose plugin, ~8 GB free disk for images,
bash. The ./cms entrypoint already carries the executable bit in git;
if a checkout loses it: chmod +x cms.
./cms walks the entire lifecycle and stops loudly at the first real
problem, telling you how to fix it:
prereqs → env → core → cms-init → prisma-sync → admin
→ contest (+ sample import if DB empty) → worker → monitor
→ superadmin prompt → health matrix summary
chmod +x cms # only needed if the bit was lost in transfer
./cms # everything, interactive where it mattersUseful variants:
./cms --yes # non-interactive (CI): prints manual cmds instead of prompting
./cms --skip worker,monitor # partial bring-up; every step is idempotent — re-run resumes
./cms --no-sample # don't import examples/contests.yaml into an empty DB
make setup # same thing via Makefile (CMS_ARGS="--no-sample" make setup)Deployment mode is picked from DEPLOYMENT_TYPE in .env.admin
(img = pull pre-built images from GHCR, src = build locally).
Override per-invocation with DEPLOYMENT_TYPE_OVERRIDE=src ./cms.
Fastest production path — pulls versioned images from GHCR.
cp .env.core.example .env.core # then edit credentials!
# ... optionally copy other .env.*.example files ...
make env # merge envs, render configs, run preflight gate
make pull # fetch all stack images
make core-img # database + RPC services (health-gated)
make cms-init # create/patch DB schema
make admin-create # interactive superadmin
make prisma-sync # sync Admin Panel schema
make contest-img admin-img infra-img
make worker-img # needs host cgroup prep (see Prerequisites)Builds the CMS image locally from src/ (all grading languages included).
Set it once in .env.admin (DEPLOYMENT_TYPE=src) or per-command:
cp .env.core.example .env.core # then edit credentials!
make env
DEPLOYMENT_TYPE=src make core # builds + starts core stack
make cms-init
make admin-create
DEPLOYMENT_TYPE=src make admin contest worker infraLegacy *-img targets still work as deprecated aliases and now force
image mode regardless of DEPLOYMENT_TYPE.
The single docker-compose.yml exposes five profiles. Cross-stack
dependencies are health-gated, so activate prerequisite profiles together:
set -a; source .env.core; set +a # or export your values
# Core first (creates shared network/volumes):
docker compose --profile core up -d --build
# Contest stack (core is its dependency — include both profiles):
docker compose --profile core --profile contest up -d --build
# Worker (host cgroup prep required) / Monitor:
docker compose --profile worker up -d
docker compose --profile monitor up -dImage-vs-source is controlled by IMG_TAG + each service's
build: block: add --build to compile from source, use
pull + up -d --no-build for registry images.
Pick by scenario:
./cms update # interactive wizard over every managed variable
# or edit .env.* directly, then:
./cms # idempotent re-run: regenerates configs, recreates changed containers./cms fix # restores missing secrets, fixes insecure defaultsgit pull && git submodule update --init --recursive
./cms update-server # safe path: preflight -> auto-backup -> rolling recreate -> health verify
# records old image digests + git HEAD to /tmp/cms-update-*.txt for manual rollback
./cms doctor # post-check if you skipped it inside update-serverupdate-server never auto-reverts. On failed health checks it prints the
recorded digests; restore with:
git checkout <recorded_git_head>
docker compose -f docker-compose.yml --profile <stack> pull # or retag digests
docker compose -f docker-compose.yml --profile core --profile <stack> up -d --no-build --force-recreate
# database rollback: scripts/__backup.sh output + scripts/__restore.sh <dump>Schema-affecting updates are covered by the automatic backup taken before
any container is recreated (make backup equivalent). Test restorability
anytime with ./cms backup drill.
One control plane for everything. Zero-arg = full bootstrap; subcommands below map 1:1 onto the Makefile and helper scripts.
| Command | Purpose |
|---|---|
./cms |
Full bootstrap lifecycle (idempotent, resumable) |
./cms setup |
First-time guided setup — fresh install or update wizard on existing installs |
./cms update |
Interactive configuration wizard (any managed variable) |
./cms fix |
Non-interactive repair of missing/insecure config |
./cms deploy <stack> [--img] |
Start one stack (core/admin/contest/worker/infra) or all; --img forces registry images |
./cms stop [stack] / clean [stack] / pull [stack] |
Lifecycle per stack or all |
./cms db init|reset|clean|sync |
Database shortcuts (init schema, full reset, wipe, Prisma sync) |
./cms admin-create |
Create a superadmin interactively |
./cms status |
Live service status dashboard |
./cms monitor |
Monitoring/backup operations UI |
./cms backup [drill] |
Full backup now; drill proves the restore path |
./cms restore <archive> |
Restore a backup archive into a scratch container |
./cms doctor |
Preflight checks only (disk, secrets, ports, cgroup) |
./cms test |
Smoke-test: boot stacks headless, verify healthchecks, teardown |
./cms worker / edit |
Fleet TUI: list/add/edit/delete workers, live status, batch deploy |
./cms worker deploy [shard] / stop |
Deploy all/some fleet entries non-interactively / stop them |
./cms worker server |
TUI: choose which main server this worker connects to |
./cms worker connect|cgroup |
Attach to a worker / prepare host cgroups (root) |
./cms contest create <yaml...> |
Batch-create contests from YAML/JSON |
./cms update-server |
Safe server update: preflight → backup → rolling recreate → verify |
Global bootstrap flags: --yes (non-interactive), --skip <a,b>,
--no-sample.
| Service | URL | Notes |
|---|---|---|
| Modern Admin Panel (Next.js) | http://localhost:8891 | Manage everything here |
| Contestant Interface | http://localhost:8888 | Per-contest port via CONTEST_ID |
| Classic Admin Panel | http://localhost:8889 | Legacy Python UI |
| Ranking | http://localhost:8890 | Live scoreboard |
Recommended exposure for admin/classic/ranking UIs: hide their raw ports and reach them through your tailnet with automatic TLS.
In .env.admin bind all three services to loopback only:
ADMIN_NEXT_BIND_IP=127.0.0.1 # admin panel :8891
ADMIN_BIND_IP=127.0.0.1 # classic admin :8889
RANKING_BIND_IP=127.0.0.1 # ranking :8890
Then ./cms deploy admin --img (recreates with new binds).
./cms expose opens an interactive matrix over all five UIs
(contest-web, nginx-front, classic-admin, ranking, admin-panel):
sel service wiring (sel → active) port url hint
> contest-web local → public 8888 http://<host>: 8888
classic-admin ts-https → local 8889 https://<node>.ts.net:8844
...
Cycle each row through local (127.0.0.1) · public (0.0.0.0) · ts-http (bound to your tailscale IP — WireGuard-encrypted plain HTTP) · ts-https (loopback + automatic browser TLS via tailscale serve), then ⏎ applies it and offers stack recreation.
Does ts-https need the tailscale IP? No. The backend stays on loopback;
tailscale servepublishes it athttps://<node>.<tailnet>.ts.net:<port>with the node's auto-renewed certificate. The IP form is only used by the separate ts-http mode.
One command registers all three listeners and can hide the raw ports:
./cms tailscale setup --hide-ports # serves + rebinds .env.admin to loopback
./cms deploy admin --img # apply the new binds
./cms tailscale status # inspect listeners + mapping
./cms tailscale remove # undoManual equivalent, if you prefer:
sudo tailscale serve --bg --https=8843 http://127.0.0.1:8891 # admin panel
sudo tailscale serve --bg --https=8844 http://127.0.0.1:8889 # classic admin
sudo tailscale serve --bg --https=8845 http://127.0.0.1:8890 # ranking
tailscale serve statusBootstrap automation: set TAILSCALE_SERVE=1 in .env.admin and every
./cms run re-registers the listeners automatically after the admin stack
is healthy.
Browse to https://<machine>.<tailnet>.ts.net:8843/ etc.
Certificates issue and renew automatically per machine.
Free-plan limit? The TLS certificate is issued per machine, not per
service — one node cert covers unlimited HTTPS listeners/ports. Portainer
on another node uses its own cert; even on this node extra serve entries
are free. No 3-service cap exists.
Traffic inside the tailnet is WireGuard-encrypted end-to-end regardless.
On each worker host (after its own ./cms bootstrap), pick the main server
it talks to:
./cms worker server # TUI: add/select main servers; Enter sets CORE_SERVICES_HOST
./cms worker deploy all # deploy local shards against the selected mainCandidates persist as WORKER_MAIN_<n>=label|host in .env.worker.
Contest web stays public through cms-nginx-contest (enable TLS there via
ENABLE_TLS=true when a public domain + certs are available).
make preflight # disk floor (3 GB), secrets, ports, cgroup — fails loudly
make lint # shellcheck + hadolint + yamllint + compose config validation
make smoke-test # boot stacks headless, poll healthchecks, teardown (keeps volumes)
make backup # full pg_dump (-Fc, incl. large objects) + volume tar + manifest
scripts/__restore.sh <dump> # restore into scratch container (never live w/o --force)
scripts/__backup_drill.sh # end-to-end restore proof
make db-clean # FULL RESET: down -v across all profilesBackups land in ./backups/{db,volumes} with SHA256 sidecars and a
rotation policy (count/age/size) enforced by the monitor container.
One docker-compose.yml, five profiles:
| Profile | Services |
|---|---|
core |
PostgreSQL · LogService · ResourceService · ScoringService · CheckerService |
admin |
AdminPanelNext (:8891) · AdminWebServer (:8889) · RankingWebServer (:8890) · optional PrintingService |
contest |
ContestWebServer (:8888+) · EvaluationService · ProxyService · nginx (TLS option) |
worker |
Sandboxed isolate workers (WORKER_SHARD unique per instance) |
monitor |
Health/backups/Discord alerting (non-root, docker.sock via DOCKER_GID) |
Startup ordering is healthcheck-gated (depends_on: condition: service_healthy) — no sleep hacks. Shared resources are plain named
volumes/network declared once; no external: coupling between stacks.
- Set
CONTEST_IDin.env.contest(canonical; legacyACTIVE_CONTEST_IDstill mapped bymake envwith a warning). Ports followCONTEST_PORT_EXTERNAL. - Remote workers: point
.env.worker'sCORE_SERVICES_HOST/POSTGRES_*at the main host, keep RPC bindings on the Tailscale IP (TAILSCALE_IPin.env.core), thenmake workeron that machine. - Batch-create contests:
./scripts/__create_contests.sh -f examples/contests.yaml(names must be codename-safe:[A-Za-z0-9_-]).
| File | Purpose |
|---|---|
.env.core |
Source of truth: DB creds, bind IPs, shards |
.env.admin |
Panel ports, DEPLOYMENT_TYPE=img|src, AUTH_SECRET |
.env.contest |
CONTEST_ID, ports, TLS, submission limits |
.env.worker |
Shard id, resource limits, cgroup path |
.env.infra |
Discord webhook, thresholds, backup rotation, DOCKER_GID |
config/cms.toml |
Rendered CMS config — regenerated by make env; containers always reach the DB as database:5432 over the compose network |
Secrets hygiene: generated files are chmod 600 on POSIX filesystems (NTFS mounts ignore chmod — preflight detects this and skips the check); preflight hard-fails on placeholder/default secrets with fix instructions.
| Symptom | Fix |
|---|---|
| Preflight aborts with placeholder-secret message | Fill real values in the named .env.* file, re-run |
worker exits citing ISOLATE_CGROUP_PATH |
Run sudo ./scripts/__worker_cgroup_setup.sh once on that host |
| Monitor can't reach docker.sock | Set DOCKER_GID in .env.infra to stat -c %g /var/run/docker.sock |
| CWS logs "no contest with the specified id" | Import a contest or align CONTEST_ID: ./scripts/__create_contests.sh -f examples/contests.yaml |
| Config changes not applying | make env never overwrites existing config/cms.toml; delete it to force regeneration |
| Disk near-full during pulls | Images total ≈ 6–7 GB; preflight aborts under 3 GB free — prune with docker system df guidance |
AGPL-3.0 (Derived from CMS)