feat: add post-create support for env key in app.json

Closes #4498
This commit is contained in:
Jose Diaz-Gonzalez
2026-01-07 03:21:04 -05:00
parent ad00918891
commit 34c336c668
14 changed files with 653 additions and 4 deletions

View File

@@ -71,6 +71,35 @@ dokku config:export --format shell node-js-app
# ENV='prod' COMPILE_ASSETS='1'
```
## Setting Environment Variables via app.json
Environment variables can also be declared in an `app.json` file in your repository root. This is useful for setting default values, generating secrets, or requiring certain variables to be set before deployment.
```json
{
"env": {
"SIMPLE_VAR": "default_value",
"SECRET_KEY": {
"description": "A secret key for signing tokens",
"generator": "secret"
},
"DATABASE_URL": {
"description": "PostgreSQL connection string",
"required": true
}
}
}
```
Environment variables from `app.json` are processed during the first deploy, before the predeploy script runs. Variables can be configured as:
- **Simple string values**: Set as defaults if not already configured
- **Generated secrets**: Use `"generator": "secret"` to auto-generate a 64-character hex string
- **Required variables**: Use `"required": true` to prompt for or require a value
- **Synced variables**: Use `"sync": true` to update the value on every deploy
For full details on the `env` schema and behavior, see the [app.json documentation](/docs/appendices/file-formats/app-json.md#env).
## Special Config Variables
The following config variables have special meanings and can be set in a variety of ways. Unless specified via global app config, the values may not be passed into applications. Usage of these values within applications should be considered unsafe, as they are an internal configuration values that may be moved to the internal properties system in the future.