Skip to content

Add target build stage configuration#396

Merged
ianpittwood merged 3 commits into
mainfrom
feature/build-target-stage
Apr 2, 2026
Merged

Add target build stage configuration#396
ianpittwood merged 3 commits into
mainfrom
feature/build-target-stage

Conversation

@ianpittwood
Copy link
Copy Markdown
Contributor

Summary

  • Adds a target: str | None field to ImageVersion and ImageMatrix config models for specifying the Docker --target build stage flag in bakery.yaml
  • Propagates target from ImageMatrix through to_image_versions() so matrix-generated versions inherit the setting
  • Threads target through ImageTarget to both build strategies: sequential (docker build --target) and bake (bake JSON target field, omitted when None)
  • Updates existing build tests to include target=None in expected call signatures; adds new tests covering target propagation and JSON serialization

Usage

versions:
  - name: 2025.01.0
    target: builder   # maps to --target builder
    os:
      - name: Ubuntu 24.04

Test plan

  • All 1172 tests pass (just test)
  • Existing test_build_args* tests updated with target=None
  • New test_build_args_with_target verifies target is passed to docker.build()
  • New TestBakeTarget tests verify target is propagated and correctly included/excluded from bake JSON

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 25, 2026

Test Results

1 235 tests  +6   1 235 ✅ +6   13m 15s ⏱️ +40s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 68851cc. ± Comparison against base commit ea57e2b.

♻️ This comment has been updated with latest results.

@ianpittwood ianpittwood force-pushed the feature/build-target-stage branch from 7035e06 to 986a408 Compare March 25, 2026 16:43
@ianpittwood ianpittwood marked this pull request as ready for review March 25, 2026 16:58
@ianpittwood ianpittwood requested a review from bschwedler as a code owner March 25, 2026 16:58
@ianpittwood ianpittwood force-pushed the feature/build-target-stage branch from 986a408 to 1cd1815 Compare March 26, 2026 20:09
@ianpittwood ianpittwood marked this pull request as draft March 26, 2026 20:26
@ianpittwood ianpittwood force-pushed the feature/build-target-stage branch 2 times, most recently from ef967d3 to 47f68f2 Compare March 30, 2026 16:10
@ianpittwood ianpittwood marked this pull request as ready for review March 30, 2026 16:10
ianpittwood and others added 3 commits March 31, 2026 12:44
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>
@ianpittwood ianpittwood force-pushed the feature/build-target-stage branch from 47f68f2 to 68851cc Compare March 31, 2026 18:44
@bschwedler bschwedler added this pull request to the merge queue Apr 2, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 2, 2026
@ianpittwood ianpittwood added this pull request to the merge queue Apr 2, 2026
Merged via the queue into main with commit ba460bd Apr 2, 2026
16 checks passed
@ianpittwood ianpittwood deleted the feature/build-target-stage branch April 2, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants