fix(infra): refuse compose up when production secrets are missing

infrastructure/docker-compose.yml had \`\${VAR:-default}\` fallbacks for
JWT_SECRET, SESSION_SECRET, and POSTGRES_PASSWORD that silently
substituted known-weak values (\`change-me-in-production\`, \`trails\`)
when the env wasn't set. A misconfigured prod deploy would happily come
up with these defaults — JWT/session forgery + a guessable Postgres
password.

Switched the four critical substitutions to \`\${VAR:?message}\` so
\`docker compose up\` fails loud instead. Mirrors the existing pattern
already used for BROUTER_URL/BROUTER_AUTH_TOKEN and (in staging) for
JWT_SECRET/SESSION_SECRET.

Sites fixed:
- journal:   DATABASE_URL (POSTGRES_PASSWORD), JWT_SECRET, SESSION_SECRET
- planner:   DATABASE_URL (POSTGRES_PASSWORD)
- postgres:  POSTGRES_PASSWORD (container itself)
- exporter:  DATA_SOURCE_NAME (POSTGRES_PASSWORD)
- staging:   both DATABASE_URLs

Production already provides all three via SOPS-encrypted
secrets.app.env, so this is a defense-in-depth change with no behavior
change on a properly-configured deploy.

Updated infrastructure/.env.example to make SESSION_SECRET explicit
(was missing) and call out the trio as required.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-05-25 22:59:09 +02:00
parent c85c757066
commit e2bf3ddb94
No known key found for this signature in database
GPG key ID: A32FF691A0F752D9
3 changed files with 12 additions and 8 deletions

View file

@ -2,8 +2,12 @@
# Copy to .env and fill in values
DOMAIN=trails.cool
# These three are REQUIRED for compose up — the production
# docker-compose.yml refuses to start without them. Generate strong
# random values; never reuse anything from this example file.
POSTGRES_PASSWORD=change-me
JWT_SECRET=change-me
SESSION_SECRET=change-me
S3_ACCESS_KEY=
S3_SECRET_KEY=