diff --git a/src/pages/selfhosted/environment-variables.mdx b/src/pages/selfhosted/environment-variables.mdx index 44530f631..c7fe53c4c 100644 --- a/src/pages/selfhosted/environment-variables.mdx +++ b/src/pages/selfhosted/environment-variables.mdx @@ -307,13 +307,30 @@ environment: ## Variable Precedence -Configuration values are applied in the following order (later values override earlier): +For the older multi-container setup, configuration values are applied in the following order (later values override earlier): 1. Default values -2. Configuration file (`config.yaml` for combined setup, `management.json` for older multi-container setup) +2. Configuration file (`management.json`) 3. Environment variables 4. Command-line flags +In v0.83.2 and earlier, the combined `netbird-server` reads `config.yaml` values only from the file and its built-in defaults. `NB_` environment variables named after `config.yaml` keys, such as `NB_SERVER_LOGLEVEL`, are ignored. The exceptions, from v0.83.0, are `NB_AUTH_SECRET` and `NB_STORE_ENCRYPTION_KEY`, which override `config.yaml`. See [Combined Server Variables](#combined-server-variables). + +For the store fields below, `config.yaml` wins. At startup, `netbird-server` copies them into the matching environment variables, replacing any value set on the container: + +| `config.yaml` field | Environment variable | +|---------------------|----------------------| +| `server.store.dsn` (when `server.store.engine` is `postgres`) | `NB_STORE_ENGINE_POSTGRES_DSN` | +| `server.store.file` | `NB_STORE_ENGINE_SQLITE_FILE` | +| `server.activityStore.engine` | `NB_ACTIVITY_EVENT_STORE_ENGINE` | +| `server.activityStore.dsn` (when `server.activityStore.engine` is set) | `NB_ACTIVITY_EVENT_POSTGRES_DSN` | +| `server.activityStore.file` | `NB_ACTIVITY_EVENT_SQLITE_FILE` | +| `server.accessLogStore.engine` | `NB_ACCESS_LOG_STORE_ENGINE` | +| `server.accessLogStore.dsn` | `NB_ACCESS_LOG_POSTGRES_DSN` | +| `server.accessLogStore.file` | `NB_ACCESS_LOG_SQLITE_FILE` | + +A variable set on the container takes effect only when its `config.yaml` field is empty, under the conditions in the table: a `server.activityStore.dsn` set without `server.activityStore.engine` is not copied, so the container's DSN is used. With `server.activityStore.engine: postgres`, the server does not start without `server.activityStore.dsn`. To take the activity DSN from the environment, leave both fields empty and set `NB_ACTIVITY_EVENT_STORE_ENGINE=postgres` and `NB_ACTIVITY_EVENT_POSTGRES_DSN`. + ## See Also - [Self-hosting Quickstart Guide](/selfhosted/selfhosted-quickstart) diff --git a/src/pages/selfhosted/maintenance/configuration-files.mdx b/src/pages/selfhosted/maintenance/configuration-files.mdx index dd269ffcb..40c3eeaf7 100644 --- a/src/pages/selfhosted/maintenance/configuration-files.mdx +++ b/src/pages/selfhosted/maintenance/configuration-files.mdx @@ -519,6 +519,8 @@ netbird-server: - NETBIRD_STORE_ENGINE_POSTGRES_DSN=host=db-server user=netbird password=secret dbname=netbird port=5432 ``` +In v0.83.2 and earlier, if `server.store.dsn` is also set in `config.yaml`, the `config.yaml` value wins. See [Variable Precedence](/selfhosted/environment-variables#variable-precedence). + See [Management Postgres Store](/selfhosted/maintenance/postgres-store) for detailed setup. ### Keeping secrets out of the config file diff --git a/src/pages/selfhosted/maintenance/postgres-store.mdx b/src/pages/selfhosted/maintenance/postgres-store.mdx index 656078b44..96ceaeac3 100644 --- a/src/pages/selfhosted/maintenance/postgres-store.mdx +++ b/src/pages/selfhosted/maintenance/postgres-store.mdx @@ -22,6 +22,8 @@ environment: - NB_STORE_ENGINE_POSTGRES_DSN=host= user= password= dbname= port= ``` +In v0.83.2 and earlier, if `server.store.dsn` is also set in `config.yaml`, the `config.yaml` value wins. See [Variable Precedence](/selfhosted/environment-variables#variable-precedence). + Restart the server and confirm: ```bash docker compose restart netbird-server