Skip to content

refactor(compose): move the image build to internal/build - #14411

Merged
glours merged 1 commit into
docker:mainfrom
ndeloof:internal-build
Nov 16, 2026
Merged

glours merged 1 commit into
docker:mainfrom
ndeloof:internal-build

Conversation

@ndeloof

@ndeloof ndeloof commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does, in one sentence

Moves the image build (the classic builder, the buildx bake builder and the choice between them) out of pkg/compose into internal/build, behind a small Backend interface.

Context

pkg/compose is one flat package where every operation is a method of the same composeService, so the build code can reach anything else in the engine (see #14396). The build is a good candidate to come out: it is a self-contained pipeline (resolve the services to build, translate them into a bake file or a classic ImageBuild call, run it, report the digests), and it only needs a handful of things from the rest of the engine.

What the PR brings

  • internal/build holds the build code and its tests, with the same assertions. It declares what it needs from the engine as a Backend of nine methods: the Docker CLI (client, credentials, terminal, buildx plugin), the event bus, the dry-run flag, the proxy settings, the concurrency limit, the canonical digest of a freshly built image, push, and the two shell-out helpers shared with the provider plugins.
  • composeService implements it and keeps a one-line build forwarder, so Build, watch and the image phase of up/run (ensureImagesExists) are untouched. ensureImagesExists and the local image digest resolution stay in pkg/compose: they are the pull/images phase of up that calls the build, not the build itself, and moving them would have doubled the Backend for no gain.
  • Two pure helpers the build shares with the rest of the engine are referenced instead of being added to the Backend: the environment resolver (also used by run) becomes its own tiny internal/envresolver package, and the Building/Built events join the other events in internal/progress.
  • Behavior is unchanged. The build-related e2e tests pass in both standalone and plugin mode. Nothing exported leaves pkg/compose: everything that moved was unexported (the bake and classic helpers, buildxMinVersion, envResolver, buildingEvent/builtEvent).

Why this is the right next brick

It follows the pattern of internal/containerops, internal/inspect and internal/provider from #14396. It does not depend on the other extractions in flight: the dependency traversal is internal/depgraph, imported directly now that its move is on main, and the image digest helpers are reached through the Backend, so it applies the same way before or after internal/images, and only the forwarders in pkg/compose/build.go would then point to the new homes.

Part of #14396

🤖 Generated with Claude Code

@ndeloof
ndeloof requested a review from docker-agent October 28, 2026 07:14
@ndeloof
ndeloof requested review from a team as code owners October 28, 2026 07:14
@ndeloof
ndeloof requested a review from glours October 28, 2026 07:14

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.46154% with 12 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/build/build.go 89.06% 7 Missing ⚠️
internal/build/bake.go 73.33% 4 Missing ⚠️
pkg/compose/run.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

@ndeloof
ndeloof force-pushed the internal-build branch 2 times, most recently from 9db33d3 to dd1345a Compare November 4, 2026 17:07
@ndeloof
ndeloof force-pushed the internal-build branch 2 times, most recently from 3d251a6 to 5983d9a Compare November 16, 2026 13:41
Comment thread internal/build/build.go Resolved
The classic and bake builders, with the dispatch between them, become
internal/build, which declares what it needs from the engine as a small
Backend. composeService implements it and keeps a one-line build
forwarder, so Build, watch and the image phase of up and run do not change.

The environment variable resolver, shared with run, becomes its own
internal/envresolver package, and the Building/Built events move to
internal/progress next to the other events.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>

@glours glours left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👍

@glours
glours enabled auto-merge (rebase) November 16, 2026 14:04

@docker-agent docker-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assessment: 🟢 APPROVE

@glours
glours merged commit 31984b1 into docker:main Nov 16, 2026
63 checks passed
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.

3 participants