From 46d5c67c1ee6db284e85f8bae716d86d7d9ee281 Mon Sep 17 00:00:00 2001 From: Juan Eugenio Abadie Date: Sat, 28 Oct 2023 18:25:06 +0200 Subject: [PATCH] Pull only when possible --- docker-build.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docker-build.sh b/docker-build.sh index b0a9b77..ab66077 100755 --- a/docker-build.sh +++ b/docker-build.sh @@ -398,6 +398,11 @@ _build_image_buildkit() { local cache_image cache_image="$(_get_full_stages_image_name)":cache + local cache_from + if _can_pull; then + cache_from="--cache-from type=registry,ref=$cache_image" + fi + local cache_to if _can_push; then cache_to="--cache-to mode=max,image-manifest=true,type=registry,ref=$cache_image" @@ -410,7 +415,7 @@ _build_image_buildkit() { # shellcheck disable=SC2086 docker buildx build \ --load \ - --cache-from type=registry,ref="$cache_image" \ + $cache_from \ $cache_to \ --tag "$DUMMY_IMAGE_NAME" \ --file "${INPUT_CONTEXT}"/"${INPUT_DOCKERFILE}" \