docker / buildx

Docker CLI plugin for extended build capabilities with BuildKit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Invalid bake target syntax still builds

crazy-max opened this issue · comments

I made a typo when writing a bake definition that contains an invalid targets field for target:

target "app" {
  dockerfile = "app.Dockerfile"
}

target "db" {
  dockerfile = "db.Dockerfile"
}

target "foo" {
  targets = ["app", "db"]
}

What's wrong is the bake definition still looks valid:

$ docker buildx bake foo --print
{
  "group": {
    "default": {
      "targets": [
        "foo"
      ]
    }
  },
  "target": {
    "foo": {
      "context": ".",
      "dockerfile": "Dockerfile"
    }
  }
}

foo should be a group here:

target "app" {
  dockerfile = "app.Dockerfile"
}

target "db" {
  dockerfile = "db.Dockerfile"
}

group "build" {
  targets = ["app", "db"]
}
$ docker buildx bake foo --print
{
  "group": {
    "default": {
      "targets": [
        "foo"
      ]
    },
    "foo": {
      "targets": [
        "app",
        "db"
      ]
    }
  },
  "target": {
    "app": {
      "context": ".",
      "dockerfile": "app.Dockerfile"
    },
    "db": {
      "context": ".",
      "dockerfile": "db.Dockerfile"
    }
  }
}

We should validate this.