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:
+16
-11
@@ -34,19 +34,24 @@ FROM php:8.2-fpm-alpine AS runtime
|
|||||||
# System deps + PHP extensions.
|
# System deps + PHP extensions.
|
||||||
# pdo_mysql -> MariaDB, intl -> Symfony, opcache -> perf, redis -> Messenger/cache transport
|
# pdo_mysql -> MariaDB, intl -> Symfony, opcache -> perf, redis -> Messenger/cache transport
|
||||||
#
|
#
|
||||||
# Extensions are installed via mlocati/install-php-extensions, which fetches
|
# IMPORTANT: the Coolify build host cannot reach pecl.php.net (the redis package
|
||||||
# PREBUILT binaries instead of compiling from source. The previous approach
|
# registry) — both `pecl install redis` and install-php-extensions failed there
|
||||||
# (pecl install redis + docker-php-ext-install) compiled redis/intl/pdo_mysql
|
# with `No releases available for package "pecl.php.net/redis"`. So redis is
|
||||||
# on every build — minutes of CPU that intermittently overran Coolify's build
|
# built directly from its GitHub source tarball instead (github.com IS
|
||||||
# timeout (exit 255). The prebuilt path is seconds and needs no .build-deps.
|
# 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; \
|
RUN set -eu; \
|
||||||
retry() { for i in 1 2 3 4 5; do "$@" && return 0; echo "retry $i: $*"; sleep 5; done; return 1; }; \
|
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 apk add --no-cache nginx supervisor icu-libs \
|
||||||
&& retry curl -sSLf https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \
|
&& retry apk add --no-cache --virtual .build-deps $PHPIZE_DEPS icu-dev \
|
||||||
-o /usr/local/bin/install-php-extensions \
|
&& docker-php-ext-install pdo_mysql intl opcache \
|
||||||
&& chmod +x /usr/local/bin/install-php-extensions \
|
&& retry curl -sSLf "https://github.com/phpredis/phpredis/archive/refs/tags/${PHPREDIS_VERSION}.tar.gz" -o /tmp/phpredis.tar.gz \
|
||||||
&& install-php-extensions pdo_mysql intl opcache redis \
|
&& mkdir -p /usr/src/php/ext/redis \
|
||||||
&& rm -f /usr/local/bin/install-php-extensions
|
&& 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
|
WORKDIR /app
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user