01 A single machine
The game fits on one OVHcloud Public Cloud instance, in the Paris region: a B3-16 model, with 4 virtual CPUs, 16 GB of memory and a 100 GB disk, running Debian 13. No load balancer, no managed database, no orchestrator: Docker Compose, one compose.yaml file, and a few shell scripts.
This choice comes from the shape of the traffic. Players mostly arrive in the morning, for the daily grid, and each request costs little: over eight hours of production, PostgreSQL spent a total of 4.6 seconds running SQL, 0.03 ms per request on average. The bottleneck is the Python CPU, and I tune it with the number of workers, not with more machines.
As you read this, the machine is using less than 2 GB of memory out of 16. The rest serves as the kernel's disk cache, which mostly benefits PostgreSQL.
The fourteen containers, by role:
| Role | Containers |
|---|---|
| Entry | caddy: HTTPS, certificates, routing |
| Application | app-blue and app-green, two copies of the same service |
| Data | db (PostgreSQL 18) and redis (real-time presence) |
| Real time | live, the WebSocket server in Rust |
| Logs | vector and victorialogs |
| Metrics | victoriametrics, node-exporter, postgres-exporter and grafana |
| Staging | app-preprod and db-preprod |
02 From commit to server
Nothing is deployed by hand. Every push to the main branch starts CI (lint, typing, tests on a real PostgreSQL); if it passes, the deploy workflow takes over.
The Docker image is built in two stages. A Node stage compiles and minifies the TypeScript and the CSS, then disappears: Node isn't in the final image. The final stage starts from a minimal Debian, installs Python and the dependencies locked with uv, copies the code and the front-end files, and hashes the names of the static files so they get cached for a year. The image is tagged with the commit SHA and published on GitHub's registry.
The workflow then copies compose.yaml and the scripts to the instance over SSH, and runs deploy.sh. Secrets follow the same path: every secret of the GitHub environment named ENV_<NAME> is written to the instance's .env, without ever appearing on a command line.
03 Blue and green
To deploy without downtime, the application exists in two copies, app-blue and app-green. Only one serves at a time. deploy.sh starts the other with the new image, waits for it to answer on /health, then tells Caddy to switch targets:
echo "to app-$next:8000" > caddy/upstream.caddy.tmp
mv caddy/upstream.caddy.tmp caddy/upstream.caddy
docker compose exec -T caddy caddy reload --config /etc/caddy/Caddyfile
Caddy's reload is hot: requests in progress finish on the old version, new ones go to the new one. The old one then receives a SIGTERM and has 30 seconds to finish its work.
The old color isn't deleted, only stopped. If the new version has a problem, rollback.sh restarts it and switches Caddy back in a few seconds.
The real-time server doesn't need this dance: it only holds WebSocket connections, which browsers reopen on their own when it restarts.
04 Caddy in front of everything
Caddy is the only container reachable from the Internet, on ports 80 and 443. It obtains and renews the Let's Encrypt certificates of all the domains on its own, compresses responses, and routes: /live/* to the real-time server, everything else to the active color.
It also does two things for the application. It writes the client's address into X-Real-IP, overwriting whatever the client might have sent, so the application can trust it. And it gives every request an identifier, which the application sends back in X-Request-Id and writes in its logs: with it, I can find everything a slow request did.
Caddy keeps no access log. It would write every player's IP address in it, and that's personal data the game doesn't need.
05 What runs on its own
Three cron jobs run commands in the active container:
- Today's grid, every hour. The server is on UTC time while the game day is Paris time: the first run after midnight, Paris time, creates the grid, and the following ones do nothing.
- Reminders, also every hour, which only send notifications at 8 am and 8 pm, Paris time.
- Backups, on the hour: a
pg_dumpof the database, kept for 48 hours, and the 4 am one kept for 14 days. When an Object Storage bucket is configured, every dump is also copied there, encrypted with age, off the instance: a backup that disappears along with the machine isn't a backup.
On the system side, unattended-upgrades applies Debian's security updates, and the firewall only lets SSH, HTTP and HTTPS in.
A trap worth knowing: Docker bypasses the firewall for the ports it publishes. The database, VictoriaLogs, VictoriaMetrics and Grafana therefore publish their port on 127.0.0.1 only. I reach them from the instance, or through an SSH tunnel, never directly from the outside:
ports:
- "127.0.0.1:5432:5432"
06 Seeing what's going on
Unhandled errors go to Sentry. For the rest, two stacks run on the machine itself.
Logs. The application and the real-time server write one JSON object per line. Vector reads Docker's log files directly from the disk, read-only, rather than through the Docker socket: that socket gives root rights over the machine, and a log collector shouldn't have them. It adds each line's service and environment, then sends it to VictoriaLogs, which keeps 30 days and 5 GiB at most. Both colors carry the same name there, service:app, so a search doesn't depend on the active color:
service:app environment:production status:>=500
Metrics. Every 30 seconds, VictoriaMetrics collects the machine's figures (CPU, memory, disk) and PostgreSQL's (connections, transactions, size), and keeps them for 30 days. Grafana shows both sources on dashboards. Each of these containers has a memory limit, and the deploy doesn't wait for them: if Grafana doesn't start, the site is still deployed.
The logs and Grafana are also plugged into Claude Code through two MCP servers. So I can ask, in plain language, which requests failed last night or how memory changed during the morning peak.
07 What has already bitten
While checking whether there was enough room left for Grafana, I found 41 GB used on the disk. The database weighed less than 200 MB, and the backups 47 MB. The rest was 273 Docker images, of which 11 were still in use.
The cause came down to one option. The deploy script cleaned up images with docker image prune -f, which only removes untagged images. But every deploy pulls an image tagged with its commit: it kept its tag, and stayed there forever. The cleanup now uses -a, which removes any image no container uses. The stopped color keeps its own, since its container still exists, and rollback still works.