docs icon indicating copy to clipboard operation
docs copied to clipboard

Precedence of environment variables and configuration files

Open the-other-dev opened this issue 1 year ago • 2 comments

Page

https://docs.directus.io/self-hosted/config-options.html#configuration-files

Describe the Inaccuracy

The documentation currently states (emphasis mine):

you can also use the CONFIG_PATH environment variable to instruct Directus to use a local configuration file instead of environment variables.

In my opinion, that is not completely accurate as the env package is reading both, the environment variables (read via process.env) and the respective CONFIG_PATH (.env, config.json, config.yaml, or config.js file).

Because of that, if I define an environment variable FOOBAR and set the environment variable CONFIG_PATH to config.json (which does not contain FOOBAR), my application would still have access to FOOBAR.

Also, it is common for environment variables to take precedence over local configuration files. For Directus, it is the other way around: The configuration files take precedence over environment variables. Thus, making it impossible to keep common configuration in a config file (and bake it into a Docker file for example) and controlling certain configuration via explicitly set environment variable (e.g. passed via -e MY_ENV_VAR in the Docker run command).

the-other-dev avatar Apr 30 '24 09:04 the-other-dev