Skip to content

Commit 179f498

Browse files
KingPinKingPin
authored andcommitted
fix(dockerfile): use POSIX-compliant arithmetic for retry backoff
Replace bash-specific exponentiation (5 * 2 ** (ATTEMPT - 1)) with POSIX sh-compatible case statement for hardcoded backoff values: - ATTEMPT 1: 5 seconds - ATTEMPT 2: 10 seconds - ATTEMPT 3: 20 seconds This fixes 'arithmetic expression: expecting primary' errors in Alpine and Debian builds which use /bin/sh instead of bash. Applies to both: - Dockerfile.v1: install-php-extensions download and installation - Dockerfile.v2: s6-overlay download
1 parent b6938e4 commit 179f498

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

Dockerfile.v1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ RUN for ATTEMPT in 1 2 3; do \
3131
break; \
3232
else \
3333
if [ $ATTEMPT -lt 3 ]; then \
34-
SLEEP_TIME=$((5 * 2 ** (ATTEMPT - 1))); \
34+
case $ATTEMPT in \
35+
1) SLEEP_TIME=5 ;; \
36+
2) SLEEP_TIME=10 ;; \
37+
3) SLEEP_TIME=20 ;; \
38+
esac; \
3539
echo "Download attempt $ATTEMPT failed, retrying in ${SLEEP_TIME}s..."; \
3640
sleep $SLEEP_TIME; \
3741
rm -f /usr/local/bin/install-php-extensions; \
@@ -48,7 +52,11 @@ RUN for ATTEMPT in 1 2 3; do \
4852
break; \
4953
else \
5054
if [ $ATTEMPT -lt 3 ]; then \
51-
SLEEP_TIME=$((5 * 2 ** (ATTEMPT - 1))); \
55+
case $ATTEMPT in \
56+
1) SLEEP_TIME=5 ;; \
57+
2) SLEEP_TIME=10 ;; \
58+
3) SLEEP_TIME=20 ;; \
59+
esac; \
5260
echo "Extension installation attempt $ATTEMPT failed, retrying in ${SLEEP_TIME}s..."; \
5361
sleep $SLEEP_TIME; \
5462
else \

Dockerfile.v2

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ RUN if [ "$BASEOS" = "trixie" ] || [ "$BASEOS" = "bookworm" ]; then \
163163
break; \
164164
else \
165165
if [ $ATTEMPT -lt 3 ]; then \
166-
SLEEP_TIME=$((5 * 2 ** (ATTEMPT - 1))); \
166+
case $ATTEMPT in \
167+
1) SLEEP_TIME=5 ;; \
168+
2) SLEEP_TIME=10 ;; \
169+
3) SLEEP_TIME=20 ;; \
170+
esac; \
167171
echo "Download attempt $ATTEMPT failed, retrying in ${SLEEP_TIME}s..."; \
168172
sleep $SLEEP_TIME; \
169173
rm -f /tmp/s6-overlay-*.tar.xz; \

0 commit comments

Comments
 (0)