Skip to content

Commit 0e14e06

Browse files
authored
fix: improve run_macaron.sh bash and docker version compatibility (#717)
Signed-off-by: Nicholas Allen <nicholas.allen@oracle.com>
1 parent a57d282 commit 0e14e06

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

scripts/release_scripts/run_macaron.sh

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,11 @@ fi
524524
USER_UID="$(id -u)"
525525
USER_GID="$(id -g)"
526526

527+
# Disable unset variable errors from here on to support older bash versions
528+
# where "${array[*]}" and "${array[@]}" expressions throw errors (in set -u mode)
529+
# when the array is empty despite otherwise having the correct behaviour.
530+
set +u
531+
527532
if [[ -z "${entrypoint[*]}" ]];
528533
then
529534
entrypoint=("macaron")
@@ -564,8 +569,22 @@ fi
564569
# Reference: https://docs.podman.io/en/v4.4/markdown/options/userns.container.html.
565570
export PODMAN_USERNS=keep-id
566571

572+
# Pull image based on DOCKER_PULL setting, emulating behaviour of
573+
# docker run --pull ${DOCKER_PULL} ...
574+
# to support older versions of docker that do not support the "--pull" argument.
575+
if [[ "${DOCKER_PULL}" == "always" ]]; then
576+
docker image pull "${IMAGE}:${MACARON_IMAGE_TAG}"
577+
elif [[ "${DOCKER_PULL}" == "missing" ]]; then
578+
docker image inspect "${IMAGE}:${MACARON_IMAGE_TAG}" &> /dev/null || docker image pull "${IMAGE}:${MACARON_IMAGE_TAG}"
579+
else
580+
# "${DOCKER_PULL}" == "never"
581+
if ! docker image inspect "${IMAGE}:${MACARON_IMAGE_TAG}" &> /dev/null; then
582+
echo "Docker image '${IMAGE}:${MACARON_IMAGE_TAG}' not found locally and DOCKER_PULL == never, aborting"
583+
exit 1
584+
fi
585+
fi
586+
567587
docker run \
568-
--pull "${DOCKER_PULL}" \
569588
--network=host \
570589
--rm -i "${tty[@]}" \
571590
-e "USER_UID=${USER_UID}" \

0 commit comments

Comments
 (0)