Skip to content

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!

@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
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