A1: Django skeleton with web and worker processes (ADR-54, ADR-55, WEB-01, WEB-07, ARC-70..74)

Django 5.2 project (config/, apps/accounts with a custom User and
case-insensitive usernames, apps/lottery with the run_worker command,
apps/web with a placeholder home and /health/live, apps/ops), SQLite in WAL
with IMMEDIATE transactions, secrets and hosts from the environment. The
compose stack is now web + worker + caddy and serves https://localhost; the
old FastAPI service is out of the stack until roadmap D1. The three old
infrastructure tests follow the new Dockerfile and compose.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
davideandClaude Sonnet 5.5 committed 2026-11-16 12:00:57 +01:00
1 parent 79f7ebe53e
commit fc23a75c9b
43 files changed
+709 -61

No files matched your search

+7 -17
View File
@@ -6,21 +6,12 @@
# instead, via its internal CA. Browsers will still warn on first visit
# unless that CA is explicitly trusted — expected for local/dev use.
{$SITE_ADDRESS:localhost} {
# gzip buffers output, which would delay delivery on the SSE stream
# (/rounds/stream, app/api/routes/rounds.py) — it needs each event flushed
# to the client immediately, not batched. Everything else still compresses.
@not_sse {
not path /rounds/stream
}
encode @not_sse gzip
encode gzip
# B-43: Caddy adds none of these on its own. The JWT lives in
# localStorage, so any XSS exfiltrates it — CSP is the main mitigation.
# script-src/style-src need 'unsafe-inline' because both SPAs
# (app/static/index.html, admin.html) use inline onclick handlers and
# style="" attributes throughout; removing those is a separate,
# larger refactor, not a header change. fonts.googleapis.com/gstatic.com
# are the one external asset (the Google Fonts @import in style.css/admin.css).
# B-43: Caddy adds none of these on its own. The session cookie is HttpOnly, but a CSP is
# still the main mitigation against injected script. 'unsafe-inline' stays for now because
# Django Admin uses inline scripts and styles; the pages of the new site (roadmap A5-A8)
# are written without them so the policy can be tightened for them later.
header {
Strict-Transport-Security "max-age=31536000; includeSubDomains"
X-Content-Type-Options "nosniff"
@@ -35,9 +26,8 @@
# registration throttles of B-33, the SSE per-IP subscriber cap of B-38) is
# defeated by simply rotating a fake value per request. Overwriting the header
# with the actual peer makes the app's assumption true at the source; it also
# reads the last hop rather than the first (app/api/client_ip.py), so the two
# defences hold independently.
reverse_proxy app:8123 {
# reads the last hop rather than the first, so the two defences hold independently.
reverse_proxy web:8000 {
header_up X-Forwarded-For {remote_host}
}
}