Description
Currently, bake allows for multiple targets to output to the same cache target. When you do so, the result is non-deterministic and mostly results in your build never caching properly, and it being a total mystery why. I've done this two different ways:
- By accident, having a somewhat complex bake file/Dockerfile, and not noticing I did a bad copy paste on a cache name
- In a Multiplatform build (see Best way to cache multi-stage + multi-platform image builds #1382) This one might already be fixed, or may only be an issue with GHA output, I'm still debugging some cache busting issues. If it's supposed to be fixed, adding validation that we never output cache targets of the same name would be neat.
I'd also say that probably one shouldn't be allowed to name two regular output targets of the same name in the same build, but I haven't actually tried to see if bake lets you.
Is there an actual use case for this? Otherwise it seems like a footgun, and should error. If there's a desire not to break existing "working" bakefiles, could go with a warning for some number of releases, first.
I've been working a lot with various docker internals for my work on clipper.dev, happy to put up a PR to fix this if it would be accepted.
Description
Currently, bake allows for multiple targets to output to the same cache target. When you do so, the result is non-deterministic and mostly results in your build never caching properly, and it being a total mystery why. I've done this two different ways:
I'd also say that probably one shouldn't be allowed to name two regular output targets of the same name in the same build, but I haven't actually tried to see if bake lets you.
Is there an actual use case for this? Otherwise it seems like a footgun, and should error. If there's a desire not to break existing "working" bakefiles, could go with a warning for some number of releases, first.
I've been working a lot with various docker internals for my work on clipper.dev, happy to put up a PR to fix this if it would be accepted.