buildx
buildx copied to clipboard
How can I append tags with --set ?
I have target like:
target "fpm-73" {
...
tags = ["repo/php:7.3-fpm", "repo/php:7.3-fpm-latest"]
}
I'm getting Minor version outside of docker-bake.hcl, e.g. 7.3.27 so I'd like to append a tag to the target tags:
docker buildx bake --print --pull --push --set fpm-73.tags=repo/php:7.3.27
Now with that ^^ the tags list from hcl file gets overriden totally.
Got around this with:
PHP_MINOR_VERSION=7.3.27 docker buildx bake --print --pull --push
And in docker-bake.hcl:
variable PHP_MINOR_VERSION {}
target "fpm-73" {
...
tags = ["repo/php:7.3-fpm", "repo/php:${PHP_MINOR_VERSION}-fpm-latest", "repo/php:7.3-fpm-latest"]
}
I don't think this is currently possible. We've discussed things like --set fpm-73.tags+=repo/php:7.3.27
We've discussed things like
--set fpm-73.tags+=repo/php:7.3.27
Personally I find mini-languages in flags a bit over the top, --set flag is already complex enough. Using HCL variables seems like a viable solution.
Yeah, I have been quite happy with HCL variable thing there ^^ It also reminds passing args to Dockerfile.
Related to https://github.com/docker/buildx/issues/901?
I took a look at this one and it seems for entitlements, annotations and attest attributes we already append: https://github.com/docker/buildx/blob/921b576f3a26a93dbe5640fe34f421e5fb3fa83c/bake/bake.go#L963-L979. In such case += is already the default for these attributes. Making them an actual override would be a breaking change :thinking:
Like:
case "annotations":
if o.Append {
t.Annotations = append(t.Annotations, o.ArrValue...)
} else {
t.Annotations = o.ArrValue
}