spire-defense: dockerize + forgejo build pipeline #2

Merged
necrogami merged 2 commits from feat/dockerize-forgejo-pipeline into main 2026-08-06 17:57:11 +00:00
Contributor

Same treatment as dark-spire (#9/#10 over there), adapted to this project's much simpler runtime.

What's in here

  • Dockerfile — python:3.13-alpine only; the whole runtime is stdlib (server.py). No node, no build step. Non-root uid 1000, healthcheck on /, port 8768. 70.7 MB image.
  • server.py — new SPIRE_DATA_DIR env var relocates the mutable state (diagnostics.db + .orient-logs/) out of the code tree; defaults to the script dir so local dev is unchanged. The /orient-logs/ GET handler's realpath containment check follows the relocation.
  • docker-compose.yml — pulls git.hl.c4.io/og_arist0tle/spire-defense:latest, mounts ./data:/data for all server state, passes SPIRE_DIAG_QUERY_KEY through, restart: unless-stopped. (Player saves are client-side localStorage — the host mount holds the diagnostics DB and orient logs.)
  • tests/ci_smoke.py — stdlib-only CI gate: boots the real server on a scratch port + scratch data dir, asserts GET / serves the game, POST /api/log → 204 with rows landing in SQLite, and the query API is 403 when no key is configured.
  • .forgejo/workflows/build.yml — smoke test on PRs; build + push :latest and :<short-sha> on merge to main. Uses the catthehacker docker-cli job image and assumes the runner's docker_host: "automount" (both already sorted from the dark-spire pipeline).

Why CI doesn't run the Playwright suite

tests/*.mjs drives real Chromium and expects a local dev setup — at least one test hardcodes /home/og/idle-games/spire-defense/diagnostics.db from another machine. Making that suite CI-portable is real work worth doing separately; ci_smoke.py covers the server surface in the meantime.

Verified locally

Smoke test green; image builds; container runs as non-root with the game served, diagnostics POST→key-gated-query roundtrip working, DB files in the /data volume (uid 1000), healthcheck healthy.

Registry secrets are already set on this repo, so merging should produce a pushed image end-to-end.

https://claude.ai/code/session_01RaLHHSp1qSk9L1oswRD8GJ

Same treatment as dark-spire (#9/#10 over there), adapted to this project's much simpler runtime. ## What's in here - **Dockerfile** — `python:3.13-alpine` only; the whole runtime is stdlib (`server.py`). No node, no build step. Non-root uid 1000, healthcheck on `/`, port 8768. **70.7 MB image.** - **server.py** — new `SPIRE_DATA_DIR` env var relocates the mutable state (`diagnostics.db` + `.orient-logs/`) out of the code tree; defaults to the script dir so local dev is unchanged. The `/orient-logs/` GET handler's realpath containment check follows the relocation. - **docker-compose.yml** — pulls `git.hl.c4.io/og_arist0tle/spire-defense:latest`, mounts `./data:/data` for all server state, passes `SPIRE_DIAG_QUERY_KEY` through, `restart: unless-stopped`. (Player saves are client-side localStorage — the host mount holds the diagnostics DB and orient logs.) - **tests/ci_smoke.py** — stdlib-only CI gate: boots the real server on a scratch port + scratch data dir, asserts `GET /` serves the game, `POST /api/log` → 204 with rows landing in SQLite, and the query API is 403 when no key is configured. - **.forgejo/workflows/build.yml** — smoke test on PRs; build + push `:latest` and `:<short-sha>` on merge to main. Uses the `catthehacker` docker-cli job image and assumes the runner's `docker_host: "automount"` (both already sorted from the dark-spire pipeline). ## Why CI doesn't run the Playwright suite `tests/*.mjs` drives real Chromium and expects a local dev setup — at least one test hardcodes `/home/og/idle-games/spire-defense/diagnostics.db` from another machine. Making that suite CI-portable is real work worth doing separately; `ci_smoke.py` covers the server surface in the meantime. ## Verified locally Smoke test green; image builds; container runs as non-root with the game served, diagnostics POST→key-gated-query roundtrip working, DB files in the `/data` volume (uid 1000), healthcheck healthy. Registry secrets are already set on this repo, so merging should produce a pushed image end-to-end. https://claude.ai/code/session_01RaLHHSp1qSk9L1oswRD8GJ
spire-defense: dockerize + forgejo build pipeline
Some checks failed
build-and-publish / test (pull_request) Failing after 3s
build-and-publish / build (pull_request) Has been skipped
b424fd65a7
- Dockerfile: python:3.13-alpine (runtime is stdlib-only), non-root,
  healthcheck on /, port 8768. 70.7 MB image.
- server.py: SPIRE_DATA_DIR env relocates diagnostics.db + .orient-logs
  (defaults to the script dir — local behavior unchanged) so the Docker
  volume /data holds all mutable state.
- docker-compose.yml: registry image, ./data:/data, SPIRE_DIAG_QUERY_KEY
  passthrough, restart unless-stopped.
- tests/ci_smoke.py: stdlib-only smoke test (boot server, GET /, POST
  /api/log, assert rows in SQLite, query API locked without key). The
  Playwright suite needs Chromium + a local dev setup and one test
  hardcodes another machine's path, so CI runs this instead.
- .forgejo/workflows/build.yml: smoke test gate on PRs; build + push
  :latest and :<short-sha> on merge to main. Uses the docker-cli job
  image + runner automount (lessons from dark-spire runs #48/#51).

Claude-Session: https://claude.ai/code/session_01RaLHHSp1qSk9L1oswRD8GJ
ci: node-based test image (checkout action needs node in the job container)
All checks were successful
build-and-publish / test (pull_request) Successful in 4s
build-and-publish / build (pull_request) Has been skipped
041625ef47
Claude-Session: https://claude.ai/code/session_01RaLHHSp1qSk9L1oswRD8GJ
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
og_arist0tle/Spire-Defense!2
No description provided.