Skip to content

Commit 8e3131a

Browse files
authored
Merge pull request #150 from whoan/push-pull-with-buildkit-only-when-possible
Stop pulling/pushing if not logged in
2 parents 8ab8dc7 + 46d5c67 commit 8e3131a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

docker-build.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -398,8 +398,13 @@ _build_image_buildkit() {
398398
local cache_image
399399
cache_image="$(_get_full_stages_image_name)":cache
400400

401+
local cache_from
402+
if _can_pull; then
403+
cache_from="--cache-from type=registry,ref=$cache_image"
404+
fi
405+
401406
local cache_to
402-
if _must_push; then
407+
if _can_push; then
403408
cache_to="--cache-to mode=max,image-manifest=true,type=registry,ref=$cache_image"
404409
fi
405410

@@ -410,7 +415,7 @@ _build_image_buildkit() {
410415
# shellcheck disable=SC2086
411416
docker buildx build \
412417
--load \
413-
--cache-from type=registry,ref="$cache_image" \
418+
$cache_from \
414419
$cache_to \
415420
--tag "$DUMMY_IMAGE_NAME" \
416421
--file "${INPUT_CONTEXT}"/"${INPUT_DOCKERFILE}" \

0 commit comments

Comments
 (0)