Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Precedence of environment variables and configuration files #22344

Open
the-other-dev opened this issue Apr 30, 2024 · 1 comment
Open

Precedence of environment variables and configuration files #22344

the-other-dev opened this issue Apr 30, 2024 · 1 comment

Comments

@the-other-dev
Copy link
Contributor

the-other-dev commented Apr 30, 2024

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

@acautin
Copy link
Contributor

acautin commented May 12, 2024

Adding to the inconsistencies, if you have the env variable FOOBAR=1 and the config entry FOOBAR=2. You will get 2 different values depending if you use @directus/env or process.env..

I remember this was not the case in older versions. Config used to override the value in the environment which then was accessed using process.env.

What are the reasons behind this change ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants