Secrets and Environment
Migration in progress. api.legendary-arena.com and PostgreSQL are moving from Render to a self-hosted DigitalOcean Ubuntu host behind Cloudflare. Render remains rollback-ready until decommission phase.
Secrets and Environment
Define and protect the server environment contract that moved from Render secret storage to host-managed secret files.
Summary
Use infra/.env.example as the placeholder reference only. Real values must never be committed.
Required posture
- Runtime secret file path: /etc/la/.env
- File mode: 600
- Owner: root (or tightly controlled service owner)
- Source of truth: secure secret manager or manual secure injection
Scope of values
The environment contract includes:
- database URL and runtime port values
- JWT and auth provider secrets
- Stripe keys and webhook secrets
- anti-abuse submit tokens
- Cloudflare R2 credentials
- Brevo alert credentials
Verification
sudo test -f /etc/la/.env
sudo stat -c '%a %U:%G %n' /etc/la/.env
Expected:
- file exists
- mode is 600
- ownership matches host policy
Installing the production values (rehearsed 2026-10-12)
The real values live only in the Render dashboard (legendary-arena-server → Environment). Copy all of them, not just the render.yaml list: some keys the server reads are set only in the dashboard.
- Click Export on Render’s Environment tab and save the file as
<folder>\render-secrets.env, where<folder>is the operator’s private ops folder. scpit to/tmp/on the droplet.- Merge it into
/etc/la/.envwithout printing any value:- Render’s values replace the matching keys.
- These keys stay as the droplet sets them:
DATABASE_URL(local Postgres),NODE_ENV,NODE_VERSION,PORT, andLEGENDS_PUBLISHER_ENABLED. - Any leftover
REPLACEplaceholder is blanked. - The file is written
600 root:root, and/tmp/render-secrets.envis shredded.
- Verify by key name only: list each key as
set/EMPTY, check for duplicates, and check that noREPLACEis left. - Redeploy (
40-app-deploy.ps1). The startup log should show the Hanko verifier against the production tenant and no errors.
Keys production doesn’t set (COACH_MODEL, the three BREVO_*_TEMPLATE_IDs) stay blank or at the code default. PAR_VERSION is left out of the file entirely. A blank PAR_VERSION= line set the empty string, which the server kept instead of its v1 default, so the PAR gate loaded nothing and every competitive score was refused as par_not_published from the cutover until legendary-arena #3354 (2026-11-13), which makes a blank value fall back to v1. To check a live server, its startup log must read “continuing with seed-only coverage (128 scenarios, v1)”, not “PAR index unavailable”. COACH_MODEL=claude-sonnet-5 is the server’s own DEFAULT_COACH_MODEL, so it behaves exactly like unset. JWT_SECRET must be Render’s value, or every signed-in session breaks at the flip.
The legends publisher holds production R2 credentials
With LEGENDS_PUBLISHER_ENABLED=true, the server writes the public legends board to the production R2 bucket every 5 minutes, built from its own database. A droplet holding production R2 keys and an empty (or stale) database would overwrite the live board. Only one publisher may run at a time, and it must be the one with the live database:
- Before cutover: the droplet runs with
LEGENDS_PUBLISHER_ENABLED=false. - At cutover, after the production restore: set it to
trueon the droplet and restartla-server. In Render’s dashboard, set it tofalse, because Render’s database goes stale the momentapi.flips. - On rollback: reverse both.
Rotation practice
- rotate compromised or shared secrets immediately
- restart service after secret updates
- document rotation event and impact window in ops notes
References
- Plan section 4.5 secrets-and-env page stub
- Plan section 10 open items and ownership notes