Skip to content

Commit

Permalink
feat: no need to pull cache_from image
Browse files Browse the repository at this point in the history
  • Loading branch information
guillaumelecerf committed Oct 29, 2024
1 parent c0716ce commit a30c1d6
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions src/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,12 @@ parse_tags_to_docker_arg() {
DOCKER_TAGS_ARG="$(eval echo $docker_arg)"
}

pull_images_from_cache() {
local cache
cache="$(eval echo $PARAM_CACHE_FROM)"

echo "$cache" | sed -n 1'p' | tr ',' '\n' | while read -r image; do
echo "Pulling ${image}";
docker pull ${image} || true
done
}

if ! parse_tags_to_docker_arg; then
echo "Unable to parse provided tags."
echo "Check your \"tag\" parameter or refer to the docs and try again: https://circleci.com/developer/orbs/orb/circleci/docker."
exit 1
fi

if [ -n "$PARAM_CACHE_FROM" ]; then
if ! pull_images_from_cache; then
echo "Unable to pull images from the cache."
echo "Check your \"cache_from\" parameter or refer to the docs and try again: https://circleci.com/developer/orbs/orb/circleci/docker."
exit 1
fi
fi

build_args=(
"--file=$PARAM_DOCKERFILE_PATH/$PARAM_DOCKERFILE_NAME"
)
Expand All @@ -62,7 +44,9 @@ if [ -n "$EXTRA_BUILD_ARGS" ]; then
fi

if [ -n "$PARAM_CACHE_FROM" ]; then
build_args+=("--cache-from=$PARAM_CACHE_FROM")
cache_from=$(eval echo $PARAM_CACHE_FROM)

build_args+=("--cache-from=$cache_from")
fi

if [ -n "$PARAM_CACHE_TO" ]; then
Expand Down

0 comments on commit a30c1d6

Please sign in to comment.