Forward ACTIVE_RECORD_ENCRYPTION_* env vars in example compose files
What
Adds the three ACTIVE_RECORD_ENCRYPTION_* keys to the shared x-rails-env anchor in compose.example.yml and compose.example.ai.yml so they are passed through to the web and worker containers when a user defines them in .env.
Why
The anchor already forwards SECRET_KEY_BASE but had no lines for the encryption keys. Because a value in .env only reaches a container when the compose file names it, a user who explicitly set the three ACTIVE_RECORD_ENCRYPTION_* keys in .env still ran with them absent from the app.
The result is that encryption of sensitive columns (e.g. API keys, provider/bank tokens) silently never took effect and those columns were stored in plaintext at rest ā with no warning, since the user believed encryption was on.
This complements #2362, which surfaces a warning when encryption isn't configured. With that warning in place but without this passthrough, a user who set the keys in .env would still see the warning persist (and stay on plaintext) because the app never actually received the keys. This change ensures that once the keys are set, they reach the app, encryption turns on, and the warning from #2362 correctly clears.
Fix
Add the keys to the anchor (inherited by both web and worker):
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: ${ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY:-}
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: ${ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY:-}
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: ${ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT:-}
The ${VAR:-} form means a user who does not set the keys gets an empty string (the documented current behaviour) with no "variable is not set" warning, so there is no change for existing setups.
Testing
Brought up the modified compose files with docker compose and checked two cases:
- Keys set in
.env: all three variables are present inside thewebandworkercontainers, and the app encrypts sensitive columns ā newly created API keys are stored encrypted rather than plaintext. - Keys not set: the variables resolve to empty strings, the stack starts normally with no errors or warnings, and behaviour is unchanged (columns remain unencrypted, exactly as before this change).
Summary by CodeRabbit
- Documentation
- Updated example configurations to show how to enable database encryption by setting Active Record encryption environment variables.