Dockflow

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.

VariableDescription
<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>_CONNECTIONThe 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_SECRETSA 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_KEYOne 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_FILEA 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:

  1. the process variables prefixed with the environment's name, and the keys of DOCKFLOW_SECRETS;
  2. .env.dockflow at the project root;
  3. the environment's SOPS file, when there is one.
.github/workflows/deploy.yml
      - 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.

.env.dockflow
PRODUCTION_CONNECTION=eyJ2IjoyLCJzZXJ2ZXJzIjpb...
DB_PASSWORD='p@ss$word'
export API_KEY="line one\nline two"
  • Blank lines and lines starting with # are ignored; a leading export is 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

VariableDescription
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_KEYThe 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_SOCKThe 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:

  1. the key in DOCKFLOW_SSH_KEY_<ENV>;
  2. the key in DOCKFLOW_SSH_KEY;
  3. the keys of ssh-agent;
  4. the IdentityFile keys ~/.ssh/config gives the host or, when it gives none, the files ~/.ssh/id_ed25519, ~/.ssh/id_ecdsa and ~/.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).

VariableDescription
DOCKFLOW_AGENT_BINARYThe 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_URLReplaces 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

VariableDescription
NO_COLORWhen 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.
TERMPassed to the server as the terminal type by dockflow ssh when it opens a terminal.

Other commands

VariableDescription
VISUAL, EDITORThe editor of dockflow secrets edit: VISUAL, else EDITOR, else vi.
XDG_CONFIG_HOMEWhere 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_USERRead 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 deploy and build.
  • The branch and commit fill DOCKFLOW_GIT_BRANCH and DOCKFLOW_GIT_SHA when the checkout does not have them (a detached or shallow clone).
  • The provider and the person are recorded in the release.
ProviderDetected byTagBranchCommitStarted by
GitHub ActionsGITHUB_ACTIONS=trueGITHUB_REF_NAME when GITHUB_REF_TYPE=tagGITHUB_HEAD_REF, else GITHUB_REF_NAMEGITHUB_SHAGITHUB_ACTOR
GitLab CIGITLAB_CI=trueCI_COMMIT_TAGCI_COMMIT_BRANCHCI_COMMIT_SHAGITLAB_USER_LOGIN
BuildkiteBUILDKITE=trueBUILDKITE_TAGBUILDKITE_BRANCH, unless it equals the tagBUILDKITE_COMMITBUILDKITE_BUILD_CREATOR, else BUILDKITE_BUILD_AUTHOR
Bitbucket PipelinesBITBUCKET_BUILD_NUMBER setBITBUCKET_TAGBITBUCKET_BRANCHBITBUCKET_COMMITBITBUCKET_STEP_TRIGGERER_UUID
JenkinsJENKINS_URL setTAG_NAMEBRANCH_NAME, else GIT_BRANCHGIT_COMMITBUILD_USER_ID
Any otherCI 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:

VariableOptionDescription
DOCKFLOW_VERSION--versionThe release to install, such as v1.0.0-alpha.6. Default: the newest release
DOCKFLOW_INSTALL_DIR--dirWhere 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 sh

The 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.

VariableValue
DOCKFLOW_APPThe app name (app: in dockflow.yml)
DOCKFLOW_ENVThe environment's name
DOCKFLOW_STACK<app>-<env>, the Compose project name of the environment
DOCKFLOW_VERSIONThe 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_SHAThe full commit, empty outside git
DOCKFLOW_GIT_BRANCHThe branch, empty on a detached checkout outside CI
DOCKFLOW_SERVERThe server's name: main unless the connection string or server.name says otherwise

Where they are available:

WhereHow
Compose files and string values of dockflow.ymlInterpolation: ${DOCKFLOW_ENV}
Files under templates: and uploads rendered as templatesJinja: {{ 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.
compose.yml
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.

Edit on GitHub

On this page