Dockerfile: fail after all retry attempts fail

This commit is contained in:
Ruoyu Zhong
2026-05-03 20:35:16 +08:00
parent 8c292b78b8
commit 2aece26170
+3 -2
View File
@@ -18,9 +18,10 @@ RUN touch /var/mail/ubuntu && chown ubuntu /var/mail/ubuntu && userdel -r ubuntu
# /etc/lsb-release is checked inside the container and sets DISTRIB_RELEASE.
# We need `[` instead of `[[` because the shell is `/bin/sh`.
# shellcheck disable=SC1091,SC2154,SC2292
RUN bash -c "for i in {1..5}; do apt-get update && break || sleep \$((i)); done" \
RUN retry() { bash -c 'for i in {1..5}; do "$@" && exit 0; [[ $((i)) -lt 5 ]] && sleep $((i)); done; exit 1' -- "$@"; } \
&& retry apt-get update \
&& apt-get install -y --no-install-recommends software-properties-common gnupg-agent \
&& if [ "$(uname -m)" != aarch64 ]; then bash -c "for i in {1..5}; do add-apt-repository -y ppa:git-core/ppa && break || sleep \$((i)); done"; fi \
&& if [ "$(uname -m)" != aarch64 ]; then retry add-apt-repository -y ppa:git-core/ppa; fi \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
acl \