Skip to main content

Environment Variables & Secrets

Applications are configured through environment variables. Miabi distinguishes between plain variables and secrets, and stores secrets in an encrypted workspace vault so sensitive values never sit in plain text.

The environment variables and secrets editor

Plain variables vs. secrets​

Plain variableSecret
ExampleLOG_LEVEL, PORT, NODE_ENVDATABASE_PASSWORD, API_KEY, JWT_SECRET
StoredAs writtenEncrypted at rest
Shown in consoleValue visibleMasked; a workspace Admin can reveal it
In logs / auditValue may appearNever shown

Use plain variables for non-sensitive configuration and secrets for anything that grants access or must stay private.

The workspace secret vault​

Secrets live in a workspace secret vault, shared across the apps in that workspace. Define a secret once and reference it from any application with ${{ secrets.NAME }} — rotate it in one place and every consumer picks up the new value on its next deploy. See Secrets for managing the vault, including custom vs. managed secrets.

All secret values are encrypted at rest and are never logged. They are returned in plain text only to a workspace Admin or Owner who explicitly reveals one — every other role sees a masked value. See Encryption for how Miabi protects them.

caution

Once a value is stored as a secret, the console masks it. For anyone below Admin a secret is write-only — to change it, set a new value rather than expecting to read the old one back.

Referencing database credentials​

When you provision a database, Miabi generates its credentials and stores them as secrets. Reference these from your application's environment instead of copying connection strings by hand. This keeps credentials in the vault, encrypted, and rotatable without editing each app manually.

Pointing one application at another​

Applications in a workspace share a network and reach each other by name, so the API at api is http://api:8080 to every sibling — no IP, no generated hostname, and nothing to update when either side is redeployed.

Set it as a plain variable:

VariableValue
API_URLhttp://api:8080

In a manifest you can have Miabi build that address for you, so the port follows the app it belongs to:

env:
API_URL: "{{ .applications.api }}" # http://api:8080
note

Both applications must be on the same node unless cluster mode is on — a workspace network is node-local otherwise. Apps deployed before Miabi 1.10 answer to their name only after their next deploy.

An application's public address​

Some apps need their own public URL at startup: OAuth callbacks, links in emails, a "public mode" that refuses to start without it. Reference it instead of copying the hostname:

VariableValue
PUBLIC_URL${{ applications.web.public_url }}
OAUTH_CALLBACK${{ applications.web.public_url }}/auth/callback

apps. works as a short alias of applications.. An app can reference itself or any other app in the workspace, and the reference can sit inside longer text.

FieldResolves to
public_urlThe app's custom domain if it has one, else its external-access URL, e.g. https://shop.example.com
public_hostThe same, without https://
external_urlThe generated external-access URL only, ignoring custom domains

The custom domain is the oldest enabled route on the app's port with path /. Routes on other ports, or on a sub-path, never count.

Miabi fills the value in each time the referencing app deploys, so it follows a base-domain change or a move to another location without editing anything. When the address changes, apps that use it are marked redeploy required; they are not restarted on their own.

A missing address fails the deploy

If the app has neither a route nor external access, the deploy fails with app "web" has no public URL: turn on external access or add a route on its port, rather than starting with an empty value. Deleting an app that others reference warns you first, naming them.

Variables Miabi sets​

Every app container and job run also gets a set of MIABI_* variables, filled in at each deploy, so an app can tag errors with its release, build its own links or tell its replicas apart without copying values by hand.

VariableValue
MIABI_APP_NAME / MIABI_APP_IDThe application
MIABI_WORKSPACE_NAME / MIABI_WORKSPACE_IDIts workspace
MIABI_STACKIts stack, when it is in one
MIABI_KINDapp, job or cronjob
MIABI_JOB_NAME / MIABI_JOB_RUN_IDThe job and this run; jobs and cron jobs only
MIABI_DEPLOYMENT_IDThe deployment that started the container
MIABI_RELEASEThe release number, e.g. 12
MIABI_VERSION / MIABI_IMAGE_TAGThe version (1.4.2) and its tag (v1.4.2), when a version policy produced the image
MIABI_COMMIT / MIABI_BRANCHSource commit and branch, for apps built from Git
MIABI_IMAGE / MIABI_IMAGE_DIGESTThe image reference and its sha256:… digest
MIABI_PORTThe app's primary container port
MIABI_INTERNAL_URLhttp://<app>:<port> on that port, how other apps in the workspace reach it
MIABI_PUBLIC_URL / MIABI_PUBLIC_HOSTThe app's public address
MIABI_LOCATIONThe location it runs in
MIABI_NODEThe node it runs on
MIABI_NODE_IDSwarm services only: the Swarm node ID of the task
MIABI_REPLICAReplica slot, 1 to n; always 1 for a container
MIABI_CPU_LIMITCPU limit in cores, e.g. 1.5
MIABI_MEMORY_LIMIT_MBMemory limit in MiB

A variable without a value is left out, never set empty: an app with no route has no MIABI_PUBLIC_URL, an app that declares no port, such as a worker, has no MIABI_PORT or MIABI_INTERNAL_URL, and an app without limits has no MIABI_CPU_LIMIT. These names are a stable contract: new ones may be added, none are renamed or removed.

A Swarm service shares one environment across its tasks, so MIABI_REPLICA and MIABI_NODE_ID are expanded by Docker in each task. A service gets MIABI_NODE only when it is pinned to a node; otherwise read MIABI_NODE_ID.

Your variables win. A variable of the same name set on the app or its stack replaces Miabi's, and the Environment tab marks it Replaces a Miabi variable. The tab also lists, under Set by Miabi, the values the next deploy sets; MIABI_RELEASE there is the running release, and the next successful deploy gets the next number.

Turning them off. Clear Set MIABI_* variables in the Environment tab, or set miabiEnv: false in the app's manifest. Jobs follow their app. The change applies at the next deploy.

Values change only at a deploy. When its workspace is renamed, the app is marked redeploy required instead of being restarted. A change to its own routes or external access does not mark it: routing applies live, and MIABI_PUBLIC_URL follows at the next deploy.

Not the pipeline set

Pipeline steps get their own MIABI_* variables. Some names are shared, but the sets differ: a running app gets no registry credentials and no MIABI_ENV file, and its MIABI_IMAGE_DIGEST is the bare sha256:… digest.

Redeploy on change​

Environment variables and secrets are baked into the running container, so changes take effect on the next deploy. After editing a variable:

  1. Save your changes in the Environment tab.
  2. Trigger a deploy (or let your pipeline do it).
  3. Miabi brings up a new release with the updated configuration, with zero downtime.
tip

Group related apps and share secrets across them with Stacks. To keep dev, staging, and production values separate, give each stage its own application — variables belong to an application, not to a promotion stage. See Environments.