Environment variables
Every environment variable dockflow reads (secrets, SSH keys, agent download, CI detection, the installer) and the built-in variables it provides to Compose, templates and hooks.
This page lists every environment variable the dockflow CLI and its installer read, grouped by use. The last section lists the built-in variables Dockflow gives to your Compose files, templates and hooks.
Dockflow reads nothing else from the environment: PATH, HOME and the rest of your variables never become secrets.
Secrets
For an environment named production, a key X is looked up as PRODUCTION_X, then X, in each source in turn. The first match wins. The full lookup order, with vars and the built-in variables, is in the dockflow.yml reference.
| Variable | Description |
|---|---|
<ENV>_<KEY> | A secret for one environment, in upper case: PRODUCTION_DB_PASSWORD is DB_PASSWORD for production. Only variables with the environment's prefix are read from the process environment. |
<ENV>_CONNECTION | The environment's connection string, printed by dockflow server connection: the server, its host key and the private key. It is read like any other secret, so it can also come from DOCKFLOW_SECRETS or .env.dockflow. When it is set, it wins over the server: of dockflow.yml. |
DOCKFLOW_SECRETS | A JSON object of secrets, typically every secret of a repository at once. Its keys follow the same rule: PRODUCTION_X, then X. String values only. |
SOPS_AGE_KEY | One or more age private keys, to decrypt the environment's SOPS file; in CI, a secret of the repository. As for the sops command. |
SOPS_AGE_KEY_FILE | A file of age private keys. Without either variable, Dockflow reads $XDG_CONFIG_HOME/sops/age/keys.txt (~/.config/sops/age/keys.txt; ~/Library/Application Support/sops/age/keys.txt on macOS), as sops does. |
The sources, in priority order:
- the process variables prefixed with the environment's name, and the keys of
DOCKFLOW_SECRETS; .env.dockflowat the project root;- the environment's SOPS file, when there is one.
- run: dockflow deploy
env:
DOCKFLOW_SECRETS: ${{ toJSON(secrets) }}.env.dockflow
A KEY=value file at the project root, for local use. Keep it out of git.
PRODUCTION_CONNECTION=eyJ2IjoyLCJzZXJ2ZXJzIjpb...
DB_PASSWORD='p@ss$word'
export API_KEY="line one\nline two"- Blank lines and lines starting with
#are ignored; a leadingexportis allowed. - Values are taken literally:
$is never expanded. - Single or double quotes around a value are removed. Inside double quotes,
\n,\t,\"and\\are understood. - In an unquoted value,
#starts a comment.
Secrets override the environment's vars of the same name. Their values are masked as *** in everything Dockflow prints. See Configuration for where they can be used.
Connecting to the server
| Variable | Description |
|---|---|
DOCKFLOW_SSH_KEY_<ENV> | The private key for one environment's server (DOCKFLOW_SSH_KEY_PRODUCTION), when the server is described under server: in dockflow.yml instead of a connection string. The value is the key itself or the path to a key file. |
DOCKFLOW_SSH_KEY | The same, for every environment without its own DOCKFLOW_SSH_KEY_<ENV>. Also the default key file of dockflow server connection when -k is not given. |
SSH_AUTH_SOCK | The ssh-agent socket. Used when no key and no password were given in any other way. |
When the server comes from dockflow.yml, Dockflow picks the private key in this order:
- the key in
DOCKFLOW_SSH_KEY_<ENV>; - the key in
DOCKFLOW_SSH_KEY; - the keys of ssh-agent;
- the
IdentityFilekeys~/.ssh/configgives the host or, when it gives none, the files~/.ssh/id_ed25519,~/.ssh/id_ecdsaand~/.ssh/id_rsa.
A key protected by a passphrase must be loaded in ssh-agent. The host key is checked against host_key: or ~/.ssh/known_hosts.
The agent binary
The CLI starts the agent on the server, which runs a Linux binary of exactly the CLI's version. When the CLI is not that binary (on macOS, on Windows, or on a different architecture), it downloads it from the release. It checks the download against the checksum the CLI was built with, and caches it in your user cache directory (~/.cache/dockflow/<version>/ on Linux).
| Variable | Description |
|---|---|
DOCKFLOW_AGENT_BINARY | The path of a dockflow binary for linux/<server's architecture>, used instead of downloading one. Required by development builds, which have no release. |
DOCKFLOW_RELEASES_URL | Replaces https://github.com/Shawiizz/dockflow/releases/download as the base URL of release downloads, for a mirror. The files are looked up under <url>/<version>/. Also read by the installer. |
Output
| Variable | Description |
|---|---|
NO_COLOR | When set to any non-empty value, the output has no colours, as with --no-color. Colours are also off when the output is not a terminal. |
TERM | Passed to the server as the terminal type by dockflow ssh when it opens a terminal. |
Other commands
| Variable | Description |
|---|---|
VISUAL, EDITOR | The editor of dockflow secrets edit: VISUAL, else EDITOR, else vi. |
XDG_CONFIG_HOME | Where the default age key file is looked up, $XDG_CONFIG_HOME/sops/age/keys.txt, when neither SOPS_AGE_KEY nor SOPS_AGE_KEY_FILE is set. |
SUDO_USER | Read by sudo dockflow server init on the server itself: the account that ran sudo, whose password login --harden-ssh keeps while it has no key. root when unset. |
CI detection
In CI, Dockflow reads the provider's variables to know the tag or branch, the commit and who started the run.
- A tag selects the environment and the version label of
deployandbuild. - The branch and commit fill
DOCKFLOW_GIT_BRANCHandDOCKFLOW_GIT_SHAwhen the checkout does not have them (a detached or shallow clone). - The provider and the person are recorded in the release.
| Provider | Detected by | Tag | Branch | Commit | Started by |
|---|---|---|---|---|---|
| GitHub Actions | GITHUB_ACTIONS=true | GITHUB_REF_NAME when GITHUB_REF_TYPE=tag | GITHUB_HEAD_REF, else GITHUB_REF_NAME | GITHUB_SHA | GITHUB_ACTOR |
| GitLab CI | GITLAB_CI=true | CI_COMMIT_TAG | CI_COMMIT_BRANCH | CI_COMMIT_SHA | GITLAB_USER_LOGIN |
| Buildkite | BUILDKITE=true | BUILDKITE_TAG | BUILDKITE_BRANCH, unless it equals the tag | BUILDKITE_COMMIT | BUILDKITE_BUILD_CREATOR, else BUILDKITE_BUILD_AUTHOR |
| Bitbucket Pipelines | BITBUCKET_BUILD_NUMBER set | BITBUCKET_TAG | BITBUCKET_BRANCH | BITBUCKET_COMMIT | BITBUCKET_STEP_TRIGGERER_UUID |
| Jenkins | JENKINS_URL set | TAG_NAME | BRANCH_NAME, else GIT_BRANCH | GIT_COMMIT | BUILD_USER_ID |
| Any other | CI set | – | – | – | – |
The providers are checked in this order; the first that matches is used. Outside CI, the release records USER (or the current system user) and the machine's host name.
Builds
Local builds run docker buildx (or podman with build.engine: podman) with your environment. The usual Docker variables, such as DOCKER_HOST, DOCKER_CONTEXT and BUILDX_BUILDER, apply to them.
Remote builds (build.builder: remote) set DOCKER_HOST to a local socket forwarded to the server's Docker, and clear DOCKER_CONTEXT and BUILDX_BUILDER. This applies to the build command only.
Temporary files go to the system's temporary directory (TMPDIR).
Installer
install.sh reads these variables, equivalent to its options:
| Variable | Option | Description |
|---|---|---|
DOCKFLOW_VERSION | --version | The release to install, such as v1.0.0-alpha.6. Default: the newest release |
DOCKFLOW_INSTALL_DIR | --dir | Where to put the binary. Default: /usr/local/bin when writable, else ~/.local/bin |
DOCKFLOW_RELEASES_URL | – | A mirror of the release downloads |
GITHUB_PATH | – | In GitHub Actions, the install directory is added to it when it is not on PATH |
curl -fsSL https://raw.githubusercontent.com/Shawiizz/dockflow/main/install.sh | DOCKFLOW_VERSION=v1.0.0-alpha.6 shThe installer's DOCKFLOW_VERSION only chooses what to install. It is unrelated to the built-in DOCKFLOW_VERSION below, which Dockflow defines itself and which your shell cannot override.
Built-in variables
Dockflow defines these variables for every environment. They come first in the lookup, before secrets and vars, so neither a secret nor a var can override them.
| Variable | Value |
|---|---|
DOCKFLOW_APP | The app name (app: in dockflow.yml) |
DOCKFLOW_ENV | The environment's name |
DOCKFLOW_STACK | <app>-<env>, the Compose project name of the environment |
DOCKFLOW_VERSION | The release's version label: --version, else the tag of a CI run without its environment suffix (1.2.0 for 1.2.0-staging), else the first 7 characters of the commit (with -dirty when the working tree has changes), else the UTC time (20261026-140311) outside a git checkout |
DOCKFLOW_GIT_SHA | The full commit, empty outside git |
DOCKFLOW_GIT_BRANCH | The branch, empty on a detached checkout outside CI |
DOCKFLOW_SERVER | The server's name: main unless the connection string or server.name says otherwise |
Where they are available:
| Where | How |
|---|---|
Compose files and string values of dockflow.yml | Interpolation: ${DOCKFLOW_ENV} |
Files under templates: and uploads rendered as templates | Jinja: {{ DOCKFLOW_VERSION }} |
Hooks (local, host and exec) | Environment variables, together with the environment's vars and the secrets the hook lists. A local hook also inherits the CLI's own process environment. |
services:
web:
image: nginx:1.27
environment:
APP_ENV: ${DOCKFLOW_ENV}
labels:
com.example.stack: ${DOCKFLOW_STACK}They are not added to your containers' environment on their own: a container sees one only when your Compose file puts it there.
Interpolating DOCKFLOW_VERSION or DOCKFLOW_GIT_SHA into a service changes its configuration on every commit, so every deploy restarts that service.
JSON events
The event stream dockflow prints with --json - the envelope, every event type and its data, run outcomes, guarantees and an example.
Server layout
What Dockflow puts on a server - the /var/lib/dockflow state directory, its containers, images, labels, networks, volumes and ports - and how to remove all of it by hand.