Environment variables
On this page
Environment variables hold your app's configuration and secrets: database URLs, API keys, feature flags. Dokwe encrypts every value before storing it and injects the variables into your app at deploy time.
How variables are layered#
Variables live at two levels:
| Level | Where you set it | Applies to |
|---|---|---|
| Project | Project → Environment tab, or dokwe env | Every environment, as shared defaults |
| Environment | Environment page → Environment Variables tab | That environment only |
When a container deploys to an environment, Dokwe merges the two lists. If a key exists at both levels, the environment value wins. Keys you set only at the project level still reach every environment. See Staging and production for how environments fit together.
Native deploys read project-level variables, combined with the env block of your dokwe.yml. The order is: env.defaults from the manifest, then project variables, then environments.<type>.env.defaults. Later sources win. See dokwe.yml reference.
Set variables in the dashboard#
Open the variables tab#
For shared defaults, open your project and choose the Environment tab. For a per-environment override, open the environment and choose Environment Variables.
Add or edit values#
In Table mode, select Add variable, enter a key and a value, then select Save changes. To paste many at once, switch to .env editor, paste the contents of a
.envfile, and save.Redeploy#
Saved changes take effect on the next deployment. On the project tab, Dokwe offers Redeploy now right after you save.
Variables prefixed with NEXT_PUBLIC_ are baked into the build. Changing one always needs a redeploy, not just a restart.
Set variables from the CLI#
The CLI manages project-level variables for the linked project. Pass --project (-p) to target a different project.
dokwe env set DATABASE_URL=postgresql://user:pass@host:5432/db
dokwe env get DATABASE_URL
dokwe env remove DATABASE_URL
dokwe env # list keys and valuesTo upload a whole file, use import. It reads .env in the current folder unless you name another file.
dokwe env import .env.productionWhen you import a file, Dokwe:
- skips blank lines and lines that start with
# - skips keys with an empty value
- removes one pair of matching single or double quotes around a value
- overwrites keys that already exist and leaves other keys alone
Keys set with dokwe env set or the table must use uppercase letters, numbers, and underscores only.
Edit a local copy#
pull, edit, and push work with a local file at .dokwe/.env.<name>. The name defaults to prod.
dokwe env pull # write variables to .dokwe/.env.prod
dokwe env edit # open the file in $EDITOR (or $VISUAL)
dokwe env push # upload the file to Dokwepull writes the file with owner-only permissions (0600). Keep .dokwe/ out of version control.
The --env flag on pull, edit, and push only chooses which local file to use, for example --env staging reads .dokwe/.env.staging. The values still go to the project-level variables. To set a value for a single environment, use the environment page in the dashboard.
Use 1Password references#
Instead of pasting a secret into the local file, write a 1Password secret reference. dokwe env push resolves every op:// reference with the 1Password CLI (op) and uploads the real values.
# .dokwe/.env.prod
DATABASE_URL=postgresql://user:pass@host:5432/mydb
DB_PASSWORD=op://production/postgres/password
API_KEY=op://production/stripe/secret_keyInstall and sign in to the 1Password CLI#
Install
op, then runop signin. In CI, setOP_SERVICE_ACCOUNT_TOKENinstead.Check your setup#
dokwe vault statusconfirms thatopis installed and signed in, and lists any references it finds in.dokwe/.env.prod.bashdokwe vault statusPreview the resolved values#
dokwe vault resolveresolves the references without uploading anything. It prints each value masked to its first and last four characters.bashdokwe vault resolvePush#
bashdokwe env push
Dokwe stores the resolved value, not the reference. If you rotate a secret in 1Password, run dokwe env push again and redeploy.
Encryption and access#
Dokwe encrypts each value with AES-256-GCM, using a fresh random IV for every value, before writing it to the database. Keys are stored in plain text so they can be listed.
Values are not write-only. Members and admins can reveal them with Show values in the dashboard or read them with dokwe env get. Viewers see variable names only; the API returns 403 INSUFFICIENT_ROLE if they ask for values.
When changes take effect#
Saving a variable doesn't change the running app. Your app picks up new values on its next deployment. Redeploy from the dashboard, run dokwe deploy, or push a commit.