directus / directus/docs

Precedence of environment variables and configuration files

Open
#321 2 comments 1 reaction 0 assignees View on GitHub
Docs
Dominant language
TypeScript
Stars
22
Forks
82
Avg merge
18h 49m
Merged PRs (30d)
4

Description

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.