Flesh out documentation on application configuration

Added documentation on little-known flags and also renamed the section "Environment Variables"
This commit is contained in:
Jose Diaz-Gonzalez
2015-10-14 05:23:57 -04:00
parent d617d12c33
commit d665dbacb9

View File

@@ -1,16 +1,57 @@
# Configuration management
# Environment Variables
Typically an application will require some configuration to run properly. Dokku supports application configuration via environment variables. Environment variables may contain private data, such as passwords or API keys, so it is not recommended to store them in your application's repository.
The `config` plugin provides the following commands to manage your variables:
```
config <app> - display the config vars for an app
config:get <app> KEY - display a config value for an app
config:set <app> KEY1=VALUE1 [KEY2=VALUE2 ...] - set one or more config vars
config:unset <app> KEY1 [KEY2 ...] - unset one or more config vars
config (<app>|--global) Display all global or app-specific config vars
config:get (<app>|--global) KEY Display a global or app-specific config value
config:set (<app>|--global) KEY1=VALUE1 [KEY2=VALUE2 ...] Set one or more config vars
config:unset (<app>|--global) KEY1 [KEY2 ...] Unset one or more config vars
```
The variables are available both at run time and during the application build/compilation step. You no longer need a `user-env` plugin as Dokku handles this functionality in a way equivalent to how Heroku handles it.
The variables are available both at run time and during the application build/compilation step.
> Note: Global `BUILD_ENV` files are currently migrated into a global `ENV` file and sourced before app-specific variables. This means that app-specific variables will take precedence over global variables. Configuring your global `ENV` file is manual, and should be considered potentially dangerous as configuration applies to all applications.
> Note: Global `ENV` files are sourced before app-specific `ENV` files. This means that app-specific variables will take precedence over global variables. Configuring your global `ENV` file is manual, and should be considered potentially dangerous as configuration applies to all applications.
You can set multiple environment variables at once:
```shell
dokku config:set node-js-app ENV=prod COMPILE_ASSETS=1
```
When setting variables with whitespace, you need to escape the whitespace:
```shell
dokku config:set node-js-app KEY=\"VAL\ WITH\ SPACES\"
```
When setting or unsetting environment variables, you may wish sometimes to avoid an application restart. This is useful when developing plugins or when setting multiple environment variables in a scripted manner. To do so, use the `--no-restart` flag:
```shell
dokku --no-restart config:set node-js-app ENV=prod
```
If you wish to have the variables output in an `eval`-compatible form, you can use the `--export` flag:
```shell
dokku config node-js-app --export
# outputs variables in the form:
#
# export ENV='prod'
# export COMPILE_ASSETS='1'
# source in all the node-js-app app environment variables
eval $(dokku config node-js-app --export)
```
You can also output the variables in a single-line for usage in command-line utilities with the `--shell` flag:
```shell
dokku config node-js-app --shell
# outputs variables in the form:
#
# ENV='prod' COMPILE_ASSETS='1'
```