Skip to content

Precedence of environment variables and configuration files #321

Open
@the-other-dev

Description

@the-other-dev

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions