Repository navigation
feat: pass build secrets to buildkit as secrets, not only build args - #255
Merged
vmelikyan merged 1 commit intoOct 9, 2026
Merged
Conversation
Dockerfiles can now read a {{aws:...}} build secret with
RUN --mount=type=secret,id=<KEY>, which keeps it out of the image.
Build args are still passed, so ARG-based Dockerfiles keep working.
liveFreeOrCode
marked this pull request as ready for review
October 7, 2026 18:10
vmelikyan
approved these changes
Oct 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Native builds pass
{{aws:...}}secrets to BuildKit only as build args (--opt build-arg). If a Dockerfile declares thatARGand uses it in aRUN, the value ends up in the image history.This change also passes each secret as a BuildKit secret:
--secret id=<KEY>,env=<KEY>next to the existing--opt build-arg:<KEY>=....RUN --mount=type=secret,id=<KEY>, and it never reaches the image.ARG-based Dockerfiles keep working unchanged.Motivating case: an image that installs from a private package index, with a Dockerfile that already reads those credentials as BuildKit secrets.
How to test
Unit tests:
cp .env.ci .env # or export its DATABASE_URL / APP_DB_* values NODE_ENV=test npx jest src/server/lib/nativeBuildEnd to end on a service with a secret env var, e.g.
NPM_TOKEN: '{{aws:repo/<repo>/<svc>:NPM_TOKEN}}':RUN --mount=type=secret,id=NPM_TOKEN cat /run/secrets/NPM_TOKEN | wc -c.docker history --no-trunc <image>and check that the value doesn't appear.Verifying Changes
jestfor native builds: 86 tests pass, including a new case for the secret flag.eslintandprettierpass.tscreports no new errors versusmain(587 before and after).moby/buildkit:v0.29.0, the image native builds use:RUN --mount=type=secretstep received the value.Notes
ARG-based Dockerfiles, so it isn't done here.