Env Var Overrides
Every Config Setting can be overridden by convention by creating environment variables in the shell where you run box. This is idea for Docker containers or CI builds were you want to easily set one-off settings and not require an entire JSON file. You set set these as actual environment variables or Java system properties of the CLI. Env vars are loaded AFTER any .cfconfig.json files have been loaded by convention and will override any settings in the JSON. They are not case sensitive.
The var must start with the text cfconfig_ and will be followed by the name of the setting.
1
cfconfig_adminPassword=myPass
Copied!
For nested settings inside of a struct or array you can use underscores to represent dots. Note the following will error if there is not already a datasource named myDSN in the server.
1
cfconfig_datasources_myDSN_password=myPass
Copied!
The overrides are applied using the same mechanism that the cfconfig set command uses, which means you can also pass JSON directly for complex values.
1
# JSON which will be parsed
2
cfconfig_mailServers=[{"port":"25","smtp":"localhost2"}]
Copied!
On OS's like Windows which allow for any manner of special characters, you can provide any string which would also be valid for the config set command. Ex:
1
# dot-delimited keys
2
cfconfig_datasources.myDSN.password=myPass
3
# array indexes too
4
cfconfig_mailServers[1].smtp=mail.server.com
Copied!
When you provide JSON, the append flag will be set to true when adding the configuration to what's already in CommandBox.
Overridden env vars will not be written to any .cfconfig.json file and will be lost when box stops. They will also take precedence and override any explicit settings already set.

Target a Lucee/Railo specific server/web context

If you want to specify a setting via an env var that targets a web context, you can use the following conventions:
1
# Default (server context)
2
cfconfig_requestTimeout=...
3
4
# Force web context. (On adobe, just loaded normally)
5
cfconfig_web_requestTimeout=...
6
7
# Force server context- same as default. (On adobe, just loaded normally)
8
cfconfig_server_requestTimeout=...
Copied!
Last modified 2mo ago