docker / docker/buildx

proposal: missing target resolution for bake

Open
#956 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/bake kind/enhancement
Dominant language
Go
Stars
4.5k
Forks
682
Avg merge
2d 14h
Merged PRs (30d)
29

Description

When buildx bake is called with target names that don't exist, instead of erroring, we could allow a better default behavior.

The default behavior could be that in that case, we assume implicit target definition:

target "<name>" {
  target: "<name>"
}

That means that we will build the target from Dockerfile with the same name. As this only works with default Dockerfile properties anyway, we could first check if the Dockerfile locally exists and return a quick error otherwise.

To give users more control over this behavior we could also define a special target name that gets called in this case. Eg.

target "_bake_target_missing" {
target "*" {

If such target is set then it would be built instead of the default behavior for names that don't have a direct match.

Inside this target, the user can use two additional variables BAKE_CURRENT_TARGET and BAKE_ALL_TARGETS . So for example they can define that default behavior for bake foo bar is to build a specific Dockerfile target and pass foo bar as a build argument.

target "_bake_target_missing" {
  args = {
    "PACKAGES": BAKE_ALL_TARGETS
  }
}

@tiborvass @crazy-max

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by locating buildx bake's target-resolution flow and review how missing targets are currently handled; done requires an agreed behavior for implicit targets or a fallback target, including the proposed variables and error handling.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
build-system, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.