Skip to content

nested inherits only affects first target #912

@maxheld83

Description

@maxheld83

it appears that inherits cannot be nested, or, (for me: worse), it only affects the first target.

For example docker buildx bake --print --file FILE on:

target "grandparent" {
  output = ["type=docker"]
}

target "parent" {
  inherits = ["grandparent"]
  args = {
    FOO = "bar"
  }
}

target "child 1" {
  inherits = ["parent"]
}

target "child 2" {
  inherits = ["parent"]
}

group "default" {
  targets = [
    "child 1",
    "child 2"
  ]
} 
{
  "group": {
    "default": {
      "targets": [
        "child 1",
        "child 2"
      ]
    }
  },
  "target": {
    "child 1": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "args": {
        "FOO": "bar"
      },
      "output": [
        "type=docker"
      ]
    },
    "child 2": {
      "context": ".",
      "dockerfile": "Dockerfile",
      "args": {
        "FOO": "bar"
      }
    }
  }
}

My expectation would have been that either:

  • both child 1 and 2 inherit output
  • neither inherit output and the parser tells me that I can't nest inherits

Took me a while to figure this out 🙃

(Amazing work on bake -- love it ❤️)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions