Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: fix multiple named contexts pointing to same bake target #2444

Merged
merged 1 commit into from May 13, 2024

Conversation

tonistiigi
Copy link
Member

Contexts using target: schema are replaced by input: pointing to previous build result before build request is sent. Currently this replacement did not work if multiple contexts pointed to the same target name.

This happened because there is a map pointing back from result to the calling context. Previously one of the contexts (with random order) would be correctly replaced and another would be sent to buildkit as target: (where it would error is something wants to use it because it can't be resolved).

Example case:

target "base" {
  target = "base"
}

target "base2" {
  target = "base2"
}

target "default" {
  contexts = {
    one = "target:base"
    two = "target:base"
    three = "target:base2"
  }

}

Contexts using target: schema are replaced by input: pointing
to previous build result before build request is sent. Currently
this replacement did not work if multiple contexts pointed to
the same target name.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
for platform, r := range rr.Refs {
st, err := r.ToState()

for _, v := range contexts {
Copy link
Member Author

Choose a reason for hiding this comment

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

View the diff with withspace disabled as only the indention changed.

@tonistiigi tonistiigi requested a review from crazy-max May 8, 2024 23:49
@tonistiigi tonistiigi merged commit 2f98e6f into docker:master May 13, 2024
102 checks passed
@crazy-max crazy-max added this to the v0.15.0 milestone May 16, 2024
@thompson-shaun thompson-shaun added the kind/bug Something isn't working label May 16, 2024
@thompson-shaun thompson-shaun modified the milestones: v0.15.0, v0.14.1 May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants