Add target build stage configuration#396
Merged
Merged
Conversation
7035e06 to
986a408
Compare
986a408 to
1cd1815
Compare
ef967d3 to
47f68f2
Compare
Adds a `target` field to `ImageVersion` and `ImageMatrix` config models, allowing users to specify the Docker `--target` flag in `bakery.yaml` for multi-stage builds. The value is threaded through `ImageTarget` to both the sequential build (`docker build`) and bake (`docker buildx bake`) paths, and is omitted from bake JSON output when not set. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Renames the config field from `target` to `buildTarget` on ImageVersion and ImageMatrix to avoid ambiguity with Docker Bake's `target` concept. The ImageTarget property becomes `build_target` (snake_case), while the BakeTarget field remains `target` to match Docker Bake's JSON schema. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds buildTarget field to Image so it can be set at the image level and inherited by all versions/matrix. Version-level buildTarget takes precedence over image-level (Version > Matrix > Image). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
47f68f2 to
68851cc
Compare
bschwedler
approved these changes
Apr 2, 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.
Summary
target: str | Nonefield toImageVersionandImageMatrixconfig models for specifying the Docker--targetbuild stage flag inbakery.yamltargetfromImageMatrixthroughto_image_versions()so matrix-generated versions inherit the settingtargetthroughImageTargetto both build strategies: sequential (docker build --target) and bake (bake JSONtargetfield, omitted whenNone)target=Nonein expected call signatures; adds new tests covering target propagation and JSON serializationUsage
Test plan
just test)test_build_args*tests updated withtarget=Nonetest_build_args_with_targetverifiestargetis passed todocker.build()TestBakeTargettests verifytargetis propagated and correctly included/excluded from bake JSON🤖 Generated with Claude Code