Skip to content

Commit cc1e120

Browse files
committed
Use alternative extension installer
Thanks to @Caroga for introducing me to https://github.com/mlocati/docker-php-extension-installer
1 parent 2979ca5 commit cc1e120

6 files changed

Lines changed: 12 additions & 16 deletions

File tree

Dockerfile-nts-alpine

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ RUN apk update \
1616
&& adduser -u 1000 -D -G app app --home /opt/app \
1717
&& touch /.you-are-in-a-wyrihaximus.net-php-docker-image
1818

19+
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
20+
1921
FROM base AS base-build
2022
RUN apk add --no-cache $PHPIZE_DEPS git libuv-dev
2123

@@ -44,18 +46,14 @@ COPY src/php/cli/conf/*.ini /usr/local/etc/php/conf.d/
4446
RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
4547
mv /*.so "$EXTENSION_DIR/" && \
4648
apk add --no-cache \
47-
gmp-dev \
48-
zlib-dev \
49-
postgresql-dev \
50-
libzip-dev \
5149
libuv-dev \
5250
coreutils \
5351
procps \
5452
git \
5553
$PHPIZE_DEPS \
5654
## Install PECL
5755
&& wget -q pear.php.net/go-pear.phar && php go-pear.phar \
58-
&& docker-php-ext-install -j$(nproc) pcntl pgsql pdo pdo_pgsql bcmath zip gmp iconv opcache \
56+
&& install-php-extensions pcntl pgsql pdo pdo_pgsql bcmath zip gmp iconv opcache \
5957
&& if [ $(php -v | grep "PHP 8.0" | wc -l) != 0 ] ; then true ; else pecl install eio; fi \
6058
&& if [ $(php -v | grep "PHP 8.0" | wc -l) != 0 ] ; then true ; else docker-php-ext-enable eio; fi \
6159
&& docker-php-ext-enable uv \

Dockerfile-nts-debian

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ RUN apt-get update \
1616
&& adduser --uid 1000 --gid 1000 --disabled-password app --home /opt/app \
1717
&& touch /.you-are-in-a-wyrihaximus.net-php-docker-image
1818

19+
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
20+
1921
FROM base AS base-build
2022
RUN yes | apt-get install $PHPIZE_DEPS git libuv1-dev
2123

Dockerfile-zts-alpine

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ RUN apk update \
1616
&& adduser -u 1000 -D -G app app --home /opt/app \
1717
&& touch /.you-are-in-a-wyrihaximus.net-php-docker-image
1818

19+
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
20+
1921
FROM base AS base-build
2022
RUN apk add --no-cache $PHPIZE_DEPS git libuv-dev
2123

@@ -44,10 +46,6 @@ COPY src/php/cli/conf/*.ini /usr/local/etc/php/conf.d/
4446
RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
4547
mv /*.so "$EXTENSION_DIR/" && \
4648
apk add --no-cache \
47-
gmp-dev \
48-
zlib-dev \
49-
postgresql-dev \
50-
libzip-dev \
5149
libuv-dev \
5250
make \
5351
git \
@@ -59,7 +57,7 @@ RUN EXTENSION_DIR=`php-config --extension-dir 2>/dev/null` && \
5957
$PHPIZE_DEPS \
6058
## Install PECL
6159
&& wget -q pear.php.net/go-pear.phar && php go-pear.phar \
62-
&& docker-php-ext-install -j$(nproc) pcntl pgsql pdo pdo_pgsql bcmath zip gmp iconv opcache \
60+
&& install-php-extensions pcntl pgsql pdo pdo_pgsql bcmath zip gmp iconv opcache \
6361
&& pecl install parallel || (cd /tmp && apk add --no-cache $PHPIZE_DEPS git && git clone https://github.com/krakjoe/parallel && cd parallel && git fetch && git pull && phpize && ./configure && make install && cd) \
6462
&& docker-php-ext-enable parallel \
6563
&& if [ $(php -v | grep "PHP 8.0" | wc -l) != 0 ] ; then true ; else pecl install eio; fi \

Dockerfile-zts-debian

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ RUN apt-get update \
1616
&& adduser --uid 1000 --gid 1000 --disabled-password app --home /opt/app \
1717
&& touch /.you-are-in-a-wyrihaximus.net-php-docker-image
1818

19+
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
20+
1921
FROM base AS base-build
2022
RUN yes | apt-get install $PHPIZE_DEPS git libuv1-dev
2123

src/php/utils/docker/alpine/install-gd-and-vips

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ apk update
66
apk add --no-cache freetype-dev libjpeg-turbo-dev libpng-dev vips-dev $PHPIZE_DEPS
77
## Initially this was an if statement to check for PHP 7.4, but since then the situation change so we're just going to try both to avoid the conditional growing out of hand
88
(docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ || docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/)
9-
docker-php-ext-install -j$(nproc) gd
10-
pecl install vips
11-
docker-php-ext-enable vips
9+
install-php-extensions gd vips
1210
rm -rf /var/cache/apk/*
1311
rm -rf /tmp/*

src/php/utils/docker/debian/install-gd-and-vips

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ apt-get update
66
yes | apt-get install libfreetype6-dev libjpeg62-turbo-dev libpng-dev libvips-dev $PHPIZE_DEPS
77
## Initially this was an if statement to check for PHP 7.4, but since then the situation change so we're just going to try both to avoid the conditional growing out of hand
88
(docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ || docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/)
9-
docker-php-ext-install -j$(nproc) gd
10-
pecl install vips
11-
docker-php-ext-enable vips
9+
install-php-extensions gd vips
1210
rm -rf /var/cache/apt/*
1311
rm -rf /tmp/*

0 commit comments

Comments
 (0)