[env]
Whether the .env files in the project root are loaded at startup.
gio.toml
[env]
files = false # the process environment is all there isBy default the server loads .env.{mode}.local, .env.local, .env.{mode} and .env before anything else, and variables already in the environment win. See .env files.
Reference
| Key | Default | Description |
|---|---|---|
filesboolean | true | Load the .env* files. Turn it off on platforms that inject the environment, so a stray file baked into an image can never add or change a variable. |
Behavior
GIO_ENV_FILES=0(orfalse) skips the files andGIO_ENV_FILES=1(ortrue) loads them, whatevergio.tomlsays. Unset or empty leaves it to the key; any other value stops startup (GIO_ENV_FILES="no" must be 0 (skip them) or 1 (load them)).- The files load before
gio.tomlis fully parsed, so this one key is read on its own first. Ifgio.tomlhas a syntax error there, orfilesis not a plain boolean, the files load and the full parse right after reports the problem. - With loading off, startup logs
not loading .env files: [env] files turns them off(orGIO_ENV_FILES), and--check-configreports"envFilesDisabledBy". - The server,
gio export,gio build standalone, the testing kit and thegioCLI all follow the key and the variable.
No key in this section logs a warning.
Examples
A container platform
Keep .env for local development, and never read it in the container:
Dockerfile
ENV GIO_ENV_FILES=0Good to know
files = "no"is a startup error:invalid type: string "no", expected a boolean.- The files are read once, at startup; restart after editing them.
Not configurable
- The
GIO_PUBLIC_prefix. Only variables namedGIO_PUBLIC_*are inlined into client bundles; every other variable stays on the server, so a secret can only reach the browser if you name it that way. NODE_ENVin a.envfile is ignored with a warning: the mode is decided before the files are read.
Related
Version history
| Version | Changes |
|---|---|
v0.1.0-beta.8 | Introduced, with GIO_ENV_FILES. The server loads .env files from this release on. |