Legendary Arena Lab

Secrets and Env

wiki

Secrets and Env

Migration in progress. api.legendary-arena.com and its PostgreSQL are moving off Render onto a self-hosted DigitalOcean Ubuntu droplet fronted by Cloudflare, per docs/PLAN.md . Until decommission, Render stays warm as the rollback target.

Summary

This page describes the environment contract for the la-server application: the full set of variables the process expects at runtime. The owning artifact infra/.env.example holds placeholders only; the real values live in a mode-600 file at /etc/la/.env on the droplet and are never committed.

Mechanics

The owning artifact is infra/.env.example . It lists every variable the server actually reads: the render.yaml keys for legendary-arena-server plus every process.env.* in apps/server, as of engine main 2026-10-04. Copy it to /etc/la/.env and fill in the real values there. 40-app-deploy.ps1 enforces root:root mode 600. systemd reads EnvironmentFile as root before dropping to the operator service user, so no unprivileged account needs to read it.

Grouped as in the file:

  1. Runtime — NODE_ENV=production, PORT=3000 (Nginx proxies to 3000; the server’s own default is 8000), WEB_CONCURRENCY=1.
  2. Database — DATABASE_URL=postgres://la:…@127.0.0.1:5432/la (co-located PostgreSQL).
  3. Auth — JWT_SECRET, HANKO_TENANT_BASE_URL, HANKO_EXPECTED_AUDIENCE, HANKO_JWKS_REFRESH_INTERVAL_MS.
  4. Payments — STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, STRIPE_PRICE_ALLOWLIST.
  5. AI coach — ANTHROPIC_API_KEY, COACH_MODEL.
  6. Public URLs, analytics, CI tokens — PUBLIC_BASE_URL, ANALYTICS_USER_ID_SALT, SWEEP_SUBMIT_TOKEN, INSPECTION_SUBMIT_TOKEN, HANDOFF_SUBMIT_TOKEN, PAR_VERSION.
  7. R2 (images + legends board) — R2_ACCOUNT_ID, R2_ACCESS_KEY_ID, R2_SECRET_ACCESS_KEY, R2_BUCKET_NAME, R2_LEGENDS_BUCKET, LEGENDS_PUBLISHER_ENABLED, LEGENDS_PUBLISHER_INTERVAL_MS.
  8. Email — BREVO_API_KEY, BREVO_LIST_ID, and the three optional BREVO_*_TEMPLATE_IDs.
  9. Dashboard DR tile (optional) — DASH_GITHUB_TOKEN, DASH_GITHUB_REPO.

Two more root-only files (600) keep operational credentials away from the app:

  • /etc/la/backup.env — the backup-bucket R2 keys, optional pCloud token and ping URL (Backup and Restore ).
  • /etc/la/monitor.env — the monitoring ping URL and thresholds (Monitoring ).

The sync: false values exist only in the Render dashboard (Environment tab). Copy them across at cutover; they are never in either repo.

Interactions

  • Deploy Server — provisions the box and installs the systemd unit whose EnvironmentFile=/etc/la/.env consumes exactly these variables.
  • PostgreSQL Setup — owns the database that DATABASE_URL addresses at localhost:5432.
  • Systemd Service — the la-server unit loads this file at process start; a missing or malformed file fails the service.
  • infra/.env.example — the committed placeholder template that defines the contract.

Edge Cases

  • The /etc/la/.env file must be mode 600 and owned appropriately; if it is world-readable, secrets are exposed, and if systemd cannot read it the EnvironmentFile load fails and the service will not start.
  • Never commit real values — only infra/.env.example with REPLACE_ME placeholders belongs in git.
  • DATABASE_URL points at localhost; any assumption of a remote managed database is wrong and will break connectivity.
  • The /etc/la directory is created by cloud-init during provisioning; if that step did not run, the copy target does not exist.

References