bake should not skip compose model normalization
closes https://github.com/docker/buildx/issues/906
Looks like this test fails: https://github.com/docker/buildx/actions/runs/4989923431/jobs/8934490857?pr=1803#step:4:581
#17 67.71 === CONT TestReadTargetsWithDotCompose
#17 67.71 bake_test.go:366:
#17 67.71 Error Trace: /src/bake/bake_test.go:366
#17 67.71 Error: Not equal:
#17 67.71 expected: "Dockerfile.webapp"
#17 67.71 actual : "Dockerfile"
#17 67.71
#17 67.71 Diff:
#17 67.71 --- Expected
#17 67.71 +++ Actual
#17 67.71 @@ -1 +1 @@
#17 67.71 -Dockerfile.webapp
#17 67.71 +Dockerfile
#17 67.71 Test: TestReadTargetsWithDotCompose
I recall we needed to skip normalization to be able to merge compose files otherwise normalization overrides some fields.
@crazy-max looking at failing test I guess this is an issue we need to fix on Compose as well
I'm not sure I understand the fix covered by TestReadTargetsWithDotCompose. sanitizeTargetName to convert web.app with web_app then merge targets with same resulting name, while those were distinct in compose
I'm not sure I understand the fix covered by TestReadTargetsWithDotCompose.
sanitizeTargetNameto convertweb.appwithweb_appthen merge targets with same resulting name, while those were distinct in compose
Yes this is because compose service name can have invalid chars for a bake target: https://github.com/docker/buildx/blob/f102ad73a8ac62b0f51ba1f19f321c0b3a7e6ccd/bake/bake.go#L36
When merging both files with normalization I have:
{
"web_app": {
"context": ".",
"dockerfile": "Dockerfile",
"args": {
"buildno": "1",
"buildno2": "12"
},
"network": ""
}
}
Without
{
"web_app": {
"context": ".",
"dockerfile": "Dockerfile.webapp",
"args": {
"buildno": "1",
"buildno2": "12"
},
"network": ""
}
}
Seems because normalization does not left dockerfile empty and set it to Dockerfile which during merging use this one: https://github.com/compose-spec/compose-go/blob/f038655338287cfe5aa4b280363796eb6e7fc41e/loader/normalize.go#L51