From 8ae35b1c8fd2d4979857538c0cac067e226dc12a Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Sun, 28 Jun 2026 10:09:32 +0330 Subject: [PATCH] fix(docker): enhance PHP extension installation with retry logic and use prebuilt binaries --- Dockerfile | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6b110232..6f4407ff 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,17 +33,20 @@ FROM php:8.2-fpm-alpine AS runtime # System deps + PHP extensions. # pdo_mysql -> MariaDB, intl -> Symfony, opcache -> perf, redis -> Messenger/cache transport -# 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. +# +# Extensions are installed via mlocati/install-php-extensions, which fetches +# PREBUILT binaries instead of compiling from source. The previous approach +# (pecl install redis + docker-php-ext-install) compiled redis/intl/pdo_mysql +# on every build — minutes of CPU that intermittently overran Coolify's build +# timeout (exit 255). The prebuilt path is seconds and needs no .build-deps. 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 \ - && retry pecl install redis \ - && docker-php-ext-enable redis \ - && apk del .build-deps + retry apk add --no-cache nginx supervisor \ + && retry curl -sSLf https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \ + -o /usr/local/bin/install-php-extensions \ + && chmod +x /usr/local/bin/install-php-extensions \ + && install-php-extensions pdo_mysql intl opcache redis \ + && rm -f /usr/local/bin/install-php-extensions WORKDIR /app