Blank SECRET_KEY_BASE in .env.example and fix guide key setup
Merged
MA
4d ago+71+71+01234567890123456789-28-28-01234567890123456789
Problem
Upstream now requires SECRET_KEY_BASE in the example compose files and documents the upgrade path (#3221, #3190). A few gaps remain around how installs get their key:
.env.examplestill shipsSECRET_KEY_BASE=secret-value. An unedited copy passes the compose check and runs on a public key shared with every other unedited install.- The Hetzner guide tells users to put
SECRET_KEY_BASE="$(openssl rand -hex 64)"into.env. Compose does not run commands in.env, so anyone who pasted it as-is runs on that literal text. - The Pipelock and MCP guides start the stack without a key step.
- The Docker upgrade section says to copy the old default from the previous
compose.yml, but the Docker and Hetzner guides download the newcompose.ymlfirst, so that value is gone by the time the user needs it. - The required-variable message in both compose files points to that same previous
compose.yml.
Changes
.env.example: leaveSECRET_KEY_BASEblank, so the compose check fails until it is set.- Compose files: the required-variable message now links to the upgrade section of the Docker guide. This is the only change to them.
- Hetzner guide: generate the key and Postgres password (now hex) in the shell and write
.envonly if it does not exist, owner-only. A note covers installs that used the old instructions. - Pipelock and MCP guides: add a key step that links to Docker Step 3 for new installs and to the upgrade section for existing ones.
- Docker guide:
- create
.envowner-only and never overwrite an existing one; - in the upgrade section, name the public values (old built-in default,
secret-value, the literal Hetzner text, guide placeholders) and say to keep the current one until the data has moved to new keys; - warn upgraders not to download
.env.example, whosepostgres/postgrescredentials differ from the compose defaults their database was created with.
- create
- Encryption guide: replace the pick-by-name steps for reading the old key from the container with a command scoped to the Compose project, which works after the new
compose.ymlis in place.
No application code changes: the public values are already in KNOWN_COMPROMISED_SECRET_KEY_BASES since #5225.
Validation
docker compose -f compose.example.yml configand-f compose.example.ai.yml configrender withSECRET_KEY_BASEset and fail with the new required-variable message when it is unset, empty, or taken from an unedited.env.example.- The key-reading command was run on throwaway Compose projects with fake keys (Compose v5.6.1) under bash, sh, dash and zsh, with the container running, stopped and missing, and with a second project on the same host.
- Ran the Hetzner heredoc and the guarded
.envcreation under bash and zsh withumask 022: a new.envis-rw-------with expanded values, and a rerun leaves an existing.envuntouched. - The old key in the docs matches
KNOWN_COMPROMISED_SECRET_KEY_BASESexactly. - All new links resolve to existing headings.