Skip to content

Commit

Permalink
Merge pull request #150 from whoan/push-pull-with-buildkit-only-when-…
Browse files Browse the repository at this point in the history
…possible

Stop pulling/pushing if not logged in
  • Loading branch information
whoan authored Oct 28, 2023
2 parents 8ab8dc7 + 46d5c67 commit 8e3131a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,13 @@ _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 _must_push; then
if _can_push; then
cache_to="--cache-to mode=max,image-manifest=true,type=registry,ref=$cache_image"
fi

Expand All @@ -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}" \
Expand Down

0 comments on commit 8e3131a

Please sign in to comment.