fix(docker): build phpredis from GitHub source (Coolify host can't reach pecl.php.net)

pecl install redis and install-php-extensions both fail on the Coolify build
host with 'No releases available for package pecl.php.net/redis' — that host
cannot reach the pecl registry. Build phpredis 6.1.0 from its GitHub source
tarball instead (github.com is reachable); pdo_mysql/intl/opcache stay as
bundled docker-php-ext-install (no network).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-28 10:34:18 +03:30
co-authored by Claude Opus 4.8
parent 8ae35b1c8f
commit 46e462c6b9
+16 -11
View File
@@ -34,19 +34,24 @@ FROM php:8.2-fpm-alpine AS runtime
# System deps + PHP extensions.
# pdo_mysql -> MariaDB, intl -> Symfony, opcache -> perf, redis -> Messenger/cache transport
#
# 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.
# IMPORTANT: the Coolify build host cannot reach pecl.php.net (the redis package
# registry) — both `pecl install redis` and install-php-extensions failed there
# with `No releases available for package "pecl.php.net/redis"`. So redis is
# built directly from its GitHub source tarball instead (github.com IS
# reachable). pdo_mysql/intl/opcache are bundled with PHP and need no network.
# retry() guards the apk/github fetches against transient mirror drops.
ENV PHPREDIS_VERSION=6.1.0
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 \
&& 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
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 curl -sSLf "https://github.com/phpredis/phpredis/archive/refs/tags/${PHPREDIS_VERSION}.tar.gz" -o /tmp/phpredis.tar.gz \
&& mkdir -p /usr/src/php/ext/redis \
&& tar -xf /tmp/phpredis.tar.gz -C /usr/src/php/ext/redis --strip-components=1 \
&& docker-php-ext-install redis \
&& rm -rf /tmp/phpredis.tar.gz \
&& apk del .build-deps
WORKDIR /app