From 8c7996c27890e209ae64156954bc85743f051de5 Mon Sep 17 00:00:00 2001 From: Florian Haas Date: Tue, 19 Nov 2024 11:11:46 +0100 Subject: [PATCH] fix: When pushing images to registry cache, use image-manifest=true MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Without this change, when building images with --cache-to-registry, BuildKit uses a proprietary cache artifact format, which breaks when using third-party registries such as Harbor or ECR. By adding the image-manifest=true option, BuildKit uses an OCI-compliant cache artifact format that should be compatible with all registries. This option requires BuildKit 0.12 or later (check with "docker buildx ls"). See https://github.com/goharbor/harbor/issues/18941 and https://github.com/moby/buildkit/issues/2251 for background information. Co-authored-by: Andrés González Fixes #1118. --- changelog.d/20241119_111602_fghaas_image_manifest.md | 8 ++++++++ tutor/commands/images.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changelog.d/20241119_111602_fghaas_image_manifest.md diff --git a/changelog.d/20241119_111602_fghaas_image_manifest.md b/changelog.d/20241119_111602_fghaas_image_manifest.md new file mode 100644 index 0000000000..28e6cc901c --- /dev/null +++ b/changelog.d/20241119_111602_fghaas_image_manifest.md @@ -0,0 +1,8 @@ +- [Improvement] When building images with + `tutor images build --cache-to-registry`, use an OCI-compliant cache + artifact format that should be universally compatible with all + registries. This enables the use of that option when working with + third-party registries such as [Harbor](https://goharbor.io/) or + [ECR](https://aws.amazon.com/ecr/). Requires + [BuildKit 0.12](https://github.com/moby/buildkit/releases/tag/v0.12.0) + or later. (by @angonz and @fghaas) diff --git a/tutor/commands/images.py b/tutor/commands/images.py index ed3174af63..2a7f53255e 100644 --- a/tutor/commands/images.py +++ b/tutor/commands/images.py @@ -227,7 +227,7 @@ def build( image_build_args.append(f"--cache-from=type=registry,ref={tag}-cache") if cache_to_registry: image_build_args.append( - f"--cache-to=type=registry,mode=max,ref={tag}-cache" + f"--cache-to=type=registry,mode=max,ref={tag}-cache,image-manifest=true" ) # Build contexts