Some Docker builds need private credentials — NPM tokens for private registries, API keys for fetching assets, SSH keys for private dependencies. Ryvn’s build action makes these available to your Dockerfile throughDocumentation Index
Fetch the complete documentation index at: https://ryvn.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
BUILD_SECRETS.
This guide walks through configuring build secrets end-to-end: declaring them in your service YAML, passing them through your GitHub workflow, and consuming them in your Dockerfile.
How it works
Your service YAML declares which build args it needs using${VAR} references. The build action resolves these from environment variables set by BUILD_SECRETS, then passes them to Docker.
Step 1: reference secrets in your service YAML
Declare the secrets your build needs asbuild.args with ${VAR} syntax. The build action uses envsubst to resolve these from environment variables at build time:
Step 2: add secrets to GitHub and pass them in your workflow
TheBUILD_SECRETS workflow secret accepts KEY=VALUE pairs, one per line. There are two ways to set this up:
- Individual secrets (recommended)
- Single combined secret
Add each secret individually to your GitHub repository’s Actions secrets (e.g. This gives you granular control — you can rotate or revoke each secret independently.
NPM_TOKEN, SOME_ACCESS_TOKEN), then compose them into BUILD_SECRETS in your workflow:KEY=VALUE pair as an environment variable, then envsubst resolves the ${VAR} references in your service’s build.args.
Step 3: use secrets in your Dockerfile
- Secret mounts (recommended)
- ARG
BuildKit secret mounts make credentials available as files during a Mount multiple secrets by chaining
RUN step without writing them to image layers. This is the recommended approach for any sensitive value.--mount flags:Common issues
Secret file is empty or missing during build
Secret file is empty or missing during build
Make sure the secret name in
--mount=type=secret,id=NPM_TOKEN matches the key name in your BUILD_SECRETS exactly (case-sensitive). Also verify that your service YAML’s build.args has a matching ${NPM_TOKEN} reference.RUN --mount=type=secret is not supported
RUN --mount=type=secret is not supported
Your Dockerfile is missing the
# syntax=docker/dockerfile:1 directive on the first line. This directive must be the very first line — before any comments or FROM instructions.Secret works locally but not in CI
Secret works locally but not in CI
Verify your GitHub Actions secrets are set correctly and that the key names in
BUILD_SECRETS match the ${VAR} references in your service YAML’s build.args. Check for typos, extra whitespace, or quotes around values.Build.args values showing up in docker history
Build.args values showing up in docker history
Any value passed as
--build-arg is baked into image layers. To prevent this, switch your Dockerfile to use --mount=type=secret instead of ARG. See the Secret mounts tab for an example.