Skip to content
New issue

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

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

Already on GitHub? # to your account

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

Merged
merged 1 commit into from
Jan 6, 2025

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
@crazy-max crazy-max force-pushed the bake-fix-missing-default branch from 7397ab3 to b6b9c05 Compare January 6, 2025 11:46
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max crazy-max force-pushed the bake-fix-missing-default branch from b6b9c05 to a90d579 Compare January 6, 2025 11:54
@tonistiigi tonistiigi merged commit 3a0eeea into docker:master Jan 6, 2025
122 checks passed
@crazy-max crazy-max deleted the bake-fix-missing-default branch January 6, 2025 19:28
Copy link

@houssam-12bboo houssam-12bboo left a comment

Choose a reason for hiding this comment

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

P

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconsistent groups behaviour with "default" target
4 participants