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

bake: fix missing default target in group's default targets #2863

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

crazy-max
Copy link
Member

fixes #2859

77b3326 made special default target not being added to targets of the default group but it should otherwise it doesn't correlate with solved targets. But it should not add a default group to it. Also fix sorting to make output consistent.

cc @klutchell

Before

target "default" {
  dockerfile = "Dockerfile"
  platforms = [
    "linux/amd64"
  ]
}

target "multiarch" {
  dockerfile = "Dockerfile"
  platforms = [
    "linux/amd64",
    "linux/arm64",
    "linux/arm/v7",
    "linux/arm/v6"
  ]
}
$ docker buildx bake --print default multiarch
{
  "group": {
    "default": {
      "targets": [
        "multiarch"
      ]
    }
  },
  "target": {
    "default": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "platforms": [
        "linux/amd64"
      ]
    },
    "multiarch": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "platforms": [
        "linux/amd64",
        "linux/arm64",
        "linux/arm/v7",
        "linux/arm/v6"
      ]
    }
  }
}
group "default" {
        targets = ["app", "multiarch"]
}
target "app" {
        dockerfile = "app.Dockerfile"
}
target "foo" {
        dockerfile = "foo.Dockerfile"
}
target "multiarch" {
        dockerfile = "Dockerfile"
        platforms = ["linux/amd64","linux/arm64","linux/arm/v7","linux/arm/v6"]
}
$ docker buildx bake --print default foo
{
  "group": {
    "default": {
      "targets": [
        "app",
        "multiarch",
        "foo"
      ]
    }
  },
  "target": {
    "app": {
      "context": ".",
      "dockerfile": "app.Dockerfile"
    },
    "foo": {
      "context": ".",
      "dockerfile": "foo.Dockerfile"
    },
    "multiarch": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "platforms": [
        "linux/amd64",
        "linux/arm64",
        "linux/arm/v7",
        "linux/arm/v6"
      ]
    }
  }
}

After

target "default" {
  dockerfile = "Dockerfile"
  platforms = [
    "linux/amd64"
  ]
}

target "multiarch" {
  dockerfile = "Dockerfile"
  platforms = [
    "linux/amd64",
    "linux/arm64",
    "linux/arm/v7",
    "linux/arm/v6"
  ]
}
$ docker buildx bake --print default multiarch
{
  "group": {
    "default": {
      "targets": [
        "default",
        "multiarch"
      ]
    }
  },
  "target": {
    "default": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "platforms": [
        "linux/amd64"
      ]
    },
    "multiarch": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "platforms": [
        "linux/amd64",
        "linux/arm64",
        "linux/arm/v7",
        "linux/arm/v6"
      ]
    }
  }
}
group "default" {
        targets = ["app", "multiarch"]
}
target "app" {
        dockerfile = "app.Dockerfile"
}
target "foo" {
        dockerfile = "foo.Dockerfile"
}
target "multiarch" {
        dockerfile = "Dockerfile"
        platforms = ["linux/amd64","linux/arm64","linux/arm/v7","linux/arm/v6"]
}
$ docker buildx bake --print default foo
{
  "group": {
    "default": {
      "targets": [
        "app",
        "foo",
        "multiarch"
      ]
    }
  },
  "target": {
    "app": {
      "context": ".",
      "dockerfile": "app.Dockerfile"
    },
    "foo": {
      "context": ".",
      "dockerfile": "foo.Dockerfile"
    },
    "multiarch": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "platforms": [
        "linux/amd64",
        "linux/arm64",
        "linux/arm/v7",
        "linux/arm/v6"
      ]
    }
  }
}

@klutchell
Copy link

Thanks for looking into this so quickly!

bake/bake.go Outdated Show resolved Hide resolved
@crazy-max crazy-max force-pushed the bake-fix-missing-default branch from 4b17931 to 7397ab3 Compare December 17, 2024 09:58
@crazy-max crazy-max requested a review from tonistiigi December 17, 2024 09:58
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.

Inconsistent groups behaviour with "default" target
3 participants