Skip to content

Split secrets out of server/.env into .env.secrets - #6

Merged
roznet merged 1 commit into
mainfrom
env-secrets-split
Nov 5, 2026
Merged

roznet merged 1 commit into
mainfrom
env-secrets-split

Conversation

@roznet

@roznet roznet commented Nov 5, 2026

Copy link
Copy Markdown
Owner

Same split as the other flyfun apps (roznet/flyfun-weather#972, roznet/flyfun-apps#41, roznet/flyfun-forms#56): plain config stays in server/.env, and secrets move to server/.env.secrets. The owner's config repo keeps that file sops-encrypted, and syncfiles decrypts it on the host (mode 600).

What

  • app/config.py: pydantic settings read (".env", ".env.secrets").
  • Compose: same design, different deploy command after the split. Every value is interpolated, with no env_file: (so host paths in .env never reach the container). Interpolation only reads .env, so once a host has .env.secrets the deploy becomes:
    docker compose --env-file .env --env-file .env.secrets -f docker-compose.prod.yml up -d
    
    DB_PASSWORD gets a ? guard: if the flags are forgotten after the split, compose refuses to start instead of running with an empty password.
  • server/.gitignore: .env.* is now ignored and the samples are re-included. The old entries didn't match .env.secrets (public repo). The Dockerfile copies only app/, static/ and templates/, so the image is unaffected.
  • Samples: DB_PASSWORD, SECRET and CERTIFICATE_PASSWORD move to a new .env.secrets.sample; .env.sample and .env.docker.example point to it.
  • designs/deployment.md: deploy commands with both env files.

Checked (docker compose config, dummy values)

Case Result
Before the split, plain up ✅ unchanged
After the split, flags forgotten ⛔ refuses, citing the guard message
After the split, --env-file .env --env-file .env.secrets ✅ secrets from .env.secrets
Flags before the split ⛔ couldn't find env file (flags only belong after the split)

Settings (the real class) reads both files, works with no .env.secrets, and the environment still wins.

Deploy order: merge, then split prod's server/.env (owner's config repo), then deploy with the two --env-file flags.

🤖 Generated with Claude Code

https://claude.ai/code/session_01W8cMQN8Qa8jZk17v72poeo

Same split as the other flyfun apps: plain configuration stays in .env,
secrets (DB_PASSWORD; SECRET and CERTIFICATE_PASSWORD for completeness)
move to .env.secrets, which the owner's config repo keeps sops-encrypted
and syncfiles decrypts on the host (mode 600).

- app/config.py: pydantic settings read (".env", ".env.secrets").
- docker-compose(.prod).yml: unchanged design (every value is interpolated,
  no env_file, so host paths in .env never reach the container). Once a
  host has .env.secrets, deploy with
    docker compose --env-file .env --env-file .env.secrets ...
  DB_PASSWORD gets a `?` guard: if the secrets file exists but the flags
  are forgotten, compose refuses to start instead of running with an empty
  password. Before the split, plain `docker compose up` works as today.
- server/.gitignore: .env.* ignored, samples re-included (public repo; the
  old entries did not match .env.secrets).
- .env.sample / .env.docker.example: secrets moved to .env.secrets.sample.
- designs/deployment.md: deploy commands with both env files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W8cMQN8Qa8jZk17v72poeo
@roznet
roznet merged commit d96530e into main Nov 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant