Invalid bake target syntax still builds
Open
Nobody has claimed this yet.
area/bake
bake-ga
kind/enhancement
status/accepted
- Dominant language
- Go
- Stars
- 4.5k
- Forks
- 682
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 29
Description
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 "foo" {
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the bake validation path exercised by docker buildx bake foo --print. Reproduce the HCL with targets inside a target and compare it with the valid group syntax; done means the invalid definition is rejected while the group definition prints app and db as its targets.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, go
- Domain
- build-system, cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100