buildx is used as a vendored dependency to implement
compose build command. With lack of a minimal "build" API/SDK, we have to copy/paste some significant amount of code, and to adjust this code to follow updates on buildx development. So we basically are always late to adopt new features.
On the other hand,
buildx evolves quickly and introduce many new features which are initially available through the
bake command using dedicated HCL syntax. While compose.yaml format is also supported, I don't expect bake to always be up-to-date with the compose specification, and especially being able to introduce new build syntax in the compose-specification would require cross repositories PR which makes our maintenance effort heavier.
My proposal is to re-implement
compose build by delegating execution to
buildx bake command, generating a
bake.hcl configuration file with everything needed based on the compose model, build flags, and specific build conditions (images to (re)build, etc).
This will enforce we get the best of buildx always available to implement
compose build, and also defines a clean separation of responsibilities so the buildx maintainers can focus on buildx core features, making builds faster and/or more flexible, while we iterate on the compose syntax and UX.
Additional environment details: This proposal comes after discussions on https://github.com/docker/compose/pull/9466#discussion_r874438992