From bca9acf356c1718b897cf00f21c495eef43cbc54 Mon Sep 17 00:00:00 2001 From: Valera V Harseko Date: Sun, 29 Nov 2026 14:14:34 +0300 Subject: [PATCH] Retry Alpine package operations and reuse repository indexes --- opendj-packages/opendj-docker/Dockerfile-alpine | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/opendj-packages/opendj-docker/Dockerfile-alpine b/opendj-packages/opendj-docker/Dockerfile-alpine index 33ad2c474a..45816d62bb 100644 --- a/opendj-packages/opendj-docker/Dockerfile-alpine +++ b/opendj-packages/opendj-docker/Dockerfile-alpine @@ -65,16 +65,27 @@ WORKDIR /opt # The headless JRE: the server and the command-line tools do not draw, and the full JRE only # adds what AWT needs to - X11, ALSA, freetype with brotli, the image codecs - along with their # CVEs. The GUI tools (control-panel) are run outside the container, against its admin port. -RUN apk add --update --no-cache --virtual builddeps curl unzip \ - && apk upgrade --update --no-cache \ +# Keep the repository indexes for this layer so add and upgrade can reuse them. +RUN apk_retry() { \ + for delay in 5 15; do \ + if apk "$@"; then return 0; fi; \ + echo "apk $* failed, retrying in ${delay}s" >&2; \ + sleep "$delay" || return; \ + done; \ + apk "$@"; \ + } \ + && apk_retry update \ + && apk_retry add --virtual builddeps curl unzip \ + && apk_retry upgrade \ && if [ "$TARGETARCH" = "386" ]; then JDK=openjdk11-jre-headless; else JDK=openjdk25-jre-headless; fi \ - && apk add bash coreutils "$JDK" \ + && apk_retry add bash coreutils "$JDK" \ && if [ -z "$VERSION" ] ; then VERSION="$(curl -i -o - --silent https://api.github.com/repos/OpenIdentityPlatform/OpenDJ/releases/latest | grep -m1 "\"name\"" | cut -d\" -f4)"; fi \ && if [ ! -f "$OPENDJ_DIST_FILENAME" ]; then echo file exists && curl -L https://github.com/OpenIdentityPlatform/OpenDJ/releases/download/$VERSION/opendj-$VERSION.zip --output $OPENDJ_DIST_FILENAME; fi \ && unzip $OPENDJ_DIST_FILENAME \ && apk del builddeps \ && apk del curl \ && apk del unzip \ + && rm -f /var/cache/apk/* \ && rm -r $OPENDJ_DIST_FILENAME \ && addgroup -S $OPENDJ_USER \ && adduser -S -u 1001 -G $OPENDJ_USER $OPENDJ_USER \