Skip to content

Commit ec083ef

Browse files
committed
Update Dockerfile
1 parent c1af6f3 commit ec083ef

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

Dockerfile

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,28 @@ RUN apt-get update && apt-get install -y \
2828
&& rm /tmp/cloudflared.deb \
2929
&& wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg \
3030
&& echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list \
31-
&& apt-get update \
31+
# Retry apt-get update with exponential backoff for Sury repository
32+
&& { \
33+
success=0; \
34+
for i in 1 2 3 4 5; do \
35+
if apt-get update; then \
36+
success=1; \
37+
break; \
38+
else \
39+
echo "apt-get update failed (attempt $i/5), retrying in $((i * 10)) seconds..."; \
40+
sleep $((i * 10)); \
41+
fi; \
42+
done; \
43+
if [ "$success" -ne 1 ]; then \
44+
echo "ERROR: apt-get update failed after 5 attempts. Sury repository may be unavailable."; \
45+
exit 1; \
46+
fi; \
47+
} \
48+
# Verify Sury repository is accessible
49+
&& apt-cache show php${PHP_VERSION}-fpm >/dev/null 2>&1 || { \
50+
echo "ERROR: php${PHP_VERSION}-fpm package not found. Sury repository may be unavailable."; \
51+
exit 1; \
52+
} \
3253
&& apt-get install -y --no-install-recommends \
3354
php${PHP_VERSION} \
3455
php${PHP_VERSION}-fpm \
@@ -90,6 +111,13 @@ RUN apt-get update && apt-get install -y \
90111
&& apt-get install -y --no-install-recommends php${PHP_VERSION}-memcache || true \
91112
&& apt-get install -y --no-install-recommends php${PHP_VERSION}-memcached || true \
92113
&& apt-get install -y --no-install-recommends php${PHP_VERSION}-opcache || true \
114+
# Final verification: ensure PHP-FPM was installed correctly
115+
&& command -v php-fpm${PHP_VERSION} >/dev/null 2>&1 || { \
116+
echo "ERROR: php-fpm${PHP_VERSION} binary not found after installation!"; \
117+
echo "This indicates the PHP installation failed. Aborting build."; \
118+
exit 1; \
119+
} \
120+
&& echo "PHP ${PHP_VERSION} installed successfully: $(php${PHP_VERSION} -v | head -1)" \
93121
&& wget -q -O /tmp/composer.phar https://getcomposer.org/download/latest-stable/composer.phar \
94122
&& SHA256=$(wget -q -O - https://getcomposer.org/download/latest-stable/composer.phar.sha256) \
95123
&& echo "$SHA256 /tmp/composer.phar" | sha256sum -c - \

0 commit comments

Comments
 (0)