mirror of
https://github.com/jkaninda/laravel-php-fpm.git
synced 2026-11-14 09:07:12 +00:00
Make PECL installs fail-fast with retries; harden integration test
This commit is contained in:
1 parent
1b1be8f55a
commit
857101583b
3 files changed
+19
-4
No files matched your search
@@ -65,7 +65,14 @@ RUN set -eux; \
|
|||||||
libxml2-dev libzip-dev zlib1g-dev; \
|
libxml2-dev libzip-dev zlib1g-dev; \
|
||||||
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \
|
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \
|
||||||
docker-php-ext-install -j"$(nproc)" bcmath exif gd intl mbstring pcntl pdo_mysql pdo_pgsql zip; \
|
docker-php-ext-install -j"$(nproc)" bcmath exif gd intl mbstring pcntl pdo_mysql pdo_pgsql zip; \
|
||||||
pecl install redis memcached rdkafka; \
|
# One extension per call with retries: pecl does not fail when one of several packages fails
|
||||||
|
for ext in redis memcached rdkafka; do \
|
||||||
|
n=0; \
|
||||||
|
until pecl install -f "$ext" && [ -f "$(php-config --extension-dir)/$ext.so" ]; do \
|
||||||
|
n=$((n + 1)); [ "$n" -ge 3 ] && { echo "pecl install $ext failed"; exit 1; }; \
|
||||||
|
sleep 10; \
|
||||||
|
done; \
|
||||||
|
done; \
|
||||||
docker-php-ext-enable redis memcached rdkafka; \
|
docker-php-ext-enable redis memcached rdkafka; \
|
||||||
# OPcache is always compiled in since PHP 8.5
|
# OPcache is always compiled in since PHP 8.5
|
||||||
if ! php -m | grep -qi '^zend opcache$'; then docker-php-ext-install opcache; fi; \
|
if ! php -m | grep -qi '^zend opcache$'; then docker-php-ext-install opcache; fi; \
|
||||||
|
|||||||
@@ -51,7 +51,14 @@ RUN set -eux; \
|
|||||||
libxml2-dev libzip-dev zlib-dev cyrus-sasl-dev linux-headers; \
|
libxml2-dev libzip-dev zlib-dev cyrus-sasl-dev linux-headers; \
|
||||||
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \
|
docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \
|
||||||
docker-php-ext-install -j"$(nproc)" bcmath exif gd intl mbstring pcntl pdo_mysql pdo_pgsql zip; \
|
docker-php-ext-install -j"$(nproc)" bcmath exif gd intl mbstring pcntl pdo_mysql pdo_pgsql zip; \
|
||||||
pecl install redis memcached rdkafka; \
|
# One extension per call with retries: pecl does not fail when one of several packages fails
|
||||||
|
for ext in redis memcached rdkafka; do \
|
||||||
|
n=0; \
|
||||||
|
until pecl install -f "$ext" && [ -f "$(php-config --extension-dir)/$ext.so" ]; do \
|
||||||
|
n=$((n + 1)); [ "$n" -ge 3 ] && { echo "pecl install $ext failed"; exit 1; }; \
|
||||||
|
sleep 10; \
|
||||||
|
done; \
|
||||||
|
done; \
|
||||||
docker-php-ext-enable redis memcached rdkafka; \
|
docker-php-ext-enable redis memcached rdkafka; \
|
||||||
# OPcache is always compiled in since PHP 8.5
|
# OPcache is always compiled in since PHP 8.5
|
||||||
if ! php -m | grep -qi '^zend opcache$'; then docker-php-ext-install opcache; fi; \
|
if ! php -m | grep -qi '^zend opcache$'; then docker-php-ext-install opcache; fi; \
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ docker run --rm "$IMAGE" php -m > modules.txt
|
|||||||
for ext in bcmath exif gd intl mbstring memcached pcntl pdo_mysql pdo_pgsql rdkafka redis zip "Zend OPcache"; do
|
for ext in bcmath exif gd intl mbstring memcached pcntl pdo_mysql pdo_pgsql rdkafka redis zip "Zend OPcache"; do
|
||||||
grep -qx "$ext" modules.txt || { echo "Missing extension: $ext"; exit 1; }
|
grep -qx "$ext" modules.txt || { echo "Missing extension: $ext"; exit 1; }
|
||||||
done
|
done
|
||||||
if docker run --rm "$IMAGE" php -m 2>&1 | grep -iE 'warning|unable to load'; then
|
if docker run --rm "$IMAGE" sh -c 'php -m 2>&1' 2>/dev/null | grep -iE 'warning|unable to load'; then
|
||||||
echo "PHP startup warnings detected"; exit 1
|
echo "PHP startup warnings detected"; exit 1
|
||||||
fi
|
fi
|
||||||
rm -f modules.txt
|
rm -f modules.txt
|
||||||
@@ -50,7 +50,8 @@ echo "==> Running migrations"
|
|||||||
docker exec --user www-data php-fpm php artisan migrate --force
|
docker exec --user www-data php-fpm php artisan migrate --force
|
||||||
|
|
||||||
echo "==> Checking HTTP response"
|
echo "==> Checking HTTP response"
|
||||||
code=$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:$HTTP_PORT")
|
# Request Nginx from inside the compose network so host port conflicts cannot interfere
|
||||||
|
code=$(docker exec php-fpm curl -s -o /dev/null -w '%{http_code}' http://nginx-server)
|
||||||
echo "HTTP $code"
|
echo "HTTP $code"
|
||||||
[ "$code" = "200" ]
|
[ "$code" = "200" ]
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user