fix(docker): implement retry logic for package installation and optimize image usage in docker-compose

This commit is contained in:
hamed
2026-06-28 09:57:11 +03:30
parent 90a908c503
commit 26fe7c4fc0
2 changed files with 16 additions and 11 deletions
+8 -3
View File
@@ -33,10 +33,15 @@ FROM php:8.2-fpm-alpine AS runtime
# System deps + PHP extensions.
# pdo_mysql -> MariaDB, intl -> Symfony, opcache -> perf, redis -> Messenger/cache transport
RUN apk add --no-cache nginx supervisor icu-libs \
&& apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev \
# apk/pecl fetch over the network; on busy build hosts the mirror occasionally
# drops a connection. retry() wraps each network step so a transient failure
# doesn't abort the whole deploy.
RUN set -eu; \
retry() { for i in 1 2 3 4 5; do "$@" && return 0; echo "retry $i: $*"; sleep 5; done; return 1; }; \
retry apk add --no-cache nginx supervisor icu-libs \
&& retry apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev \
&& docker-php-ext-install pdo_mysql intl opcache \
&& pecl install redis \
&& retry pecl install redis \
&& docker-php-ext-enable redis \
&& apk del .build-deps