Environment and secrets

Manage runtime environment variables, Dockerfile build args, BuildKit secret mounts, and encrypted credential delivery.

Open an application's Environment tab to add keys individually, bulk-import via Paste .env, or configure an optional container env file. Formatio stores variables and secrets in the control-plane database encrypted with AES-256-GCM, then decrypts them for authorized edits, builds, and deployment.

[!IMPORTANT] Saving environment changes writes configuration only. Choose Deploy/Redeploy to inject updated values into running containers. Restart recycles containers using their previous snapshot.

Variable and secret behavior by builder

Build path Build-time behavior Runtime behavior
Dockerfile: Variable Passed as Docker build argument (ARG KEY) Injected into container environment
Dockerfile: Secret Mounted ephemeral at /run/secrets/<KEY> via BuildKit Exported securely by runtime entrypoint wrapper
Railpack Exposed during build toolchain execution Injected into running application environment
Nixpacks Passed via build options (persisted in image env) Injected into running application environment
Custom image No build runs Injected into running application environment

[!WARNING] Do not store build-only credentials as Variables or inside Nixpacks builds—build args and Nixpacks build options can persist in image layer history. Use Dockerfile with BuildKit Secrets instead, and never include server credentials in browser-bundled VITE_* or NEXT_PUBLIC_* keys.

Use Dockerfile BuildKit secrets

Add sensitive build tokens such as PACKAGE_TOKEN as a Secret (not Variable), then consume them via a BuildKit secret mount without persisting them in image layers:

# syntax=docker/dockerfile:1
RUN --mount=type=secret,id=PACKAGE_TOKEN,required=true \
    PACKAGE_TOKEN="$(cat /run/secrets/PACKAGE_TOKEN)" ./scripts/install-private-deps.sh

A shell-sourceable bundle containing all build secrets is also mounted at secret ID app_env. Use plain Variable + ARG only for non-sensitive flags such as NODE_ENV or APP_MODE.

Add, paste, or connect private services

  • Choose Paste .env to import standard KEY=VALUE lines cleanly and verify each row's Variable vs. Secret toggle before saving.
  • For service-to-service connections inside the same project, reference the sibling service's private hostname from networking (for example http://api:8080).

Optional env file generation

Turning on Write an env file writes merged runtime values to a relative filename inside the container working directory (for example .env.runtime), while still injecting normal process environment variables. Path traversal outside the working directory is rejected.

  • Legacy Dockerfile apps default to writing .env into build context; Railpack and Nixpacks disable build env files by default.
  • Add generated env filenames to .dockerignore before running COPY . . so build secrets never enter final layers.

Runtime delivery and credential rotation

Formatio delivers runtime secrets over mounted secret storage and an entrypoint wrapper requiring /bin/sh. Minimal distroless or scratch images without /bin/sh must supply a shell or read environment variables via direct image config.

Rotate a secret safely

  1. Generate the new credential at the external provider while keeping the old one active temporarily.
  2. Update the secret value on Environment, save, and run Deploy/Redeploy.
  3. Verify the running deployment in Runtime logs and Traces, then revoke the old credential upstream.

Further reading