From 133e890274152201649acb950584eeea028abfbd Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Wed, 14 Aug 2019 14:37:30 +1000 Subject: [PATCH] Add Composer to the PHP image (#8) --- 5.2/php/Dockerfile | 3 +++ 5.3/php/Dockerfile | 25 ++++++++++++++++++- 5.4/php/Dockerfile | 22 +++++++++++++++-- 5.5/php/Dockerfile | 22 +++++++++++++++-- 5.6/php/Dockerfile | 22 +++++++++++++++-- 7.0/php/Dockerfile | 22 +++++++++++++++-- 7.1/php/Dockerfile | 22 +++++++++++++++-- 7.2/php/Dockerfile | 22 +++++++++++++++-- 7.3/php/Dockerfile | 22 +++++++++++++++-- 7.4/php/Dockerfile | 22 +++++++++++++++-- 8.0/php/Dockerfile | 24 ++++++++++++++++++- Dockerfile-php.template | 3 +++ update.php | 53 +++++++++++++++++++++++++++++++---------- 13 files changed, 254 insertions(+), 30 deletions(-) diff --git a/5.2/php/Dockerfile b/5.2/php/Dockerfile index f07a0da..c549052 100644 --- a/5.2/php/Dockerfile +++ b/5.2/php/Dockerfile @@ -8,6 +8,9 @@ WORKDIR /var/www # # +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + COPY entrypoint.sh /entrypoint.sh diff --git a/5.3/php/Dockerfile b/5.3/php/Dockerfile index 9ae8ca3..bdbd441 100644 --- a/5.3/php/Dockerfile +++ b/5.3/php/Dockerfile @@ -8,7 +8,30 @@ WORKDIR /var/www # # - +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + +# install the PHP extensions we need +RUN set -ex; \ + \ + apt-get update; \ + \ + apt-get install -y --no-install-recommends unzip; \ + \ + curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://getcomposer.org/installer; \ + curl --silent --fail --location --retry 3 --output /tmp/installer.sig --url https://composer.github.io/installer.sig; \ + php -r " \ + \$signature = file_get_contents( '/tmp/installer.sig' ); \ + \$hash = hash( 'sha384', file_get_contents('/tmp/installer.php') ); \ + if ( \$signature !== \$hash ) { \ + unlink( '/tmp/installer.php' ); \ + unlink( '/tmp/installer.sig' ); \ + echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ + exit( 1 ); \ + }"; \ + php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer; \ + composer --ansi --version --no-interaction; \ + rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh diff --git a/5.4/php/Dockerfile b/5.4/php/Dockerfile index 77b2ec3..b10cfc9 100644 --- a/5.4/php/Dockerfile +++ b/5.4/php/Dockerfile @@ -8,19 +8,37 @@ WORKDIR /var/www # # +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + # install the PHP extensions we need RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ \ docker-php-ext-install gd mysql mysqli zip; \ \ pecl install xdebug-2.4.1; \ - pecl install memcached-2.2.0; + pecl install memcached-2.2.0; \ + \ + curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://getcomposer.org/installer; \ + curl --silent --fail --location --retry 3 --output /tmp/installer.sig --url https://composer.github.io/installer.sig; \ + php -r " \ + \$signature = file_get_contents( '/tmp/installer.sig' ); \ + \$hash = hash( 'sha384', file_get_contents('/tmp/installer.php') ); \ + if ( \$signature !== \$hash ) { \ + unlink( '/tmp/installer.php' ); \ + unlink( '/tmp/installer.sig' ); \ + echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ + exit( 1 ); \ + }"; \ + php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer; \ + composer --ansi --version --no-interaction; \ + rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh diff --git a/5.5/php/Dockerfile b/5.5/php/Dockerfile index 9446b6b..94166e7 100644 --- a/5.5/php/Dockerfile +++ b/5.5/php/Dockerfile @@ -8,19 +8,37 @@ WORKDIR /var/www # # +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + # install the PHP extensions we need RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ \ docker-php-ext-install gd mysql mysqli zip; \ \ pecl install xdebug-2.5.5; \ - pecl install memcached-2.2.0; + pecl install memcached-2.2.0; \ + \ + curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://getcomposer.org/installer; \ + curl --silent --fail --location --retry 3 --output /tmp/installer.sig --url https://composer.github.io/installer.sig; \ + php -r " \ + \$signature = file_get_contents( '/tmp/installer.sig' ); \ + \$hash = hash( 'sha384', file_get_contents('/tmp/installer.php') ); \ + if ( \$signature !== \$hash ) { \ + unlink( '/tmp/installer.php' ); \ + unlink( '/tmp/installer.sig' ); \ + echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ + exit( 1 ); \ + }"; \ + php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer; \ + composer --ansi --version --no-interaction; \ + rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh diff --git a/5.6/php/Dockerfile b/5.6/php/Dockerfile index 44381ad..811a952 100644 --- a/5.6/php/Dockerfile +++ b/5.6/php/Dockerfile @@ -8,19 +8,37 @@ WORKDIR /var/www # # +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + # install the PHP extensions we need RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ \ docker-php-ext-install gd mysql mysqli zip; \ \ pecl install xdebug-2.5.5; \ - pecl install memcached-2.2.0; + pecl install memcached-2.2.0; \ + \ + curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://getcomposer.org/installer; \ + curl --silent --fail --location --retry 3 --output /tmp/installer.sig --url https://composer.github.io/installer.sig; \ + php -r " \ + \$signature = file_get_contents( '/tmp/installer.sig' ); \ + \$hash = hash( 'sha384', file_get_contents('/tmp/installer.php') ); \ + if ( \$signature !== \$hash ) { \ + unlink( '/tmp/installer.php' ); \ + unlink( '/tmp/installer.sig' ); \ + echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ + exit( 1 ); \ + }"; \ + php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer; \ + composer --ansi --version --no-interaction; \ + rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh diff --git a/7.0/php/Dockerfile b/7.0/php/Dockerfile index c57eb58..6b0eda3 100644 --- a/7.0/php/Dockerfile +++ b/7.0/php/Dockerfile @@ -8,19 +8,37 @@ WORKDIR /var/www # # +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + # install the PHP extensions we need RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ \ docker-php-ext-install gd opcache mysqli zip; \ \ pecl install xdebug-2.7.2; \ - pecl install memcached-3.1.3; + pecl install memcached-3.1.3; \ + \ + curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://getcomposer.org/installer; \ + curl --silent --fail --location --retry 3 --output /tmp/installer.sig --url https://composer.github.io/installer.sig; \ + php -r " \ + \$signature = file_get_contents( '/tmp/installer.sig' ); \ + \$hash = hash( 'sha384', file_get_contents('/tmp/installer.php') ); \ + if ( \$signature !== \$hash ) { \ + unlink( '/tmp/installer.php' ); \ + unlink( '/tmp/installer.sig' ); \ + echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ + exit( 1 ); \ + }"; \ + php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer; \ + composer --ansi --version --no-interaction; \ + rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh diff --git a/7.1/php/Dockerfile b/7.1/php/Dockerfile index d327d88..5823f3d 100644 --- a/7.1/php/Dockerfile +++ b/7.1/php/Dockerfile @@ -8,19 +8,37 @@ WORKDIR /var/www # # +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + # install the PHP extensions we need RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ \ docker-php-ext-install gd opcache mysqli zip; \ \ pecl install xdebug-2.7.2; \ - pecl install memcached-3.1.3; + pecl install memcached-3.1.3; \ + \ + curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://getcomposer.org/installer; \ + curl --silent --fail --location --retry 3 --output /tmp/installer.sig --url https://composer.github.io/installer.sig; \ + php -r " \ + \$signature = file_get_contents( '/tmp/installer.sig' ); \ + \$hash = hash( 'sha384', file_get_contents('/tmp/installer.php') ); \ + if ( \$signature !== \$hash ) { \ + unlink( '/tmp/installer.php' ); \ + unlink( '/tmp/installer.sig' ); \ + echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ + exit( 1 ); \ + }"; \ + php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer; \ + composer --ansi --version --no-interaction; \ + rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh diff --git a/7.2/php/Dockerfile b/7.2/php/Dockerfile index 8c88697..324b199 100644 --- a/7.2/php/Dockerfile +++ b/7.2/php/Dockerfile @@ -8,19 +8,37 @@ WORKDIR /var/www # # +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + # install the PHP extensions we need RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ \ docker-php-ext-install gd opcache mysqli zip; \ \ pecl install xdebug-2.7.2; \ - pecl install memcached-3.1.3; + pecl install memcached-3.1.3; \ + \ + curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://getcomposer.org/installer; \ + curl --silent --fail --location --retry 3 --output /tmp/installer.sig --url https://composer.github.io/installer.sig; \ + php -r " \ + \$signature = file_get_contents( '/tmp/installer.sig' ); \ + \$hash = hash( 'sha384', file_get_contents('/tmp/installer.php') ); \ + if ( \$signature !== \$hash ) { \ + unlink( '/tmp/installer.php' ); \ + unlink( '/tmp/installer.sig' ); \ + echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ + exit( 1 ); \ + }"; \ + php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer; \ + composer --ansi --version --no-interaction; \ + rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh diff --git a/7.3/php/Dockerfile b/7.3/php/Dockerfile index 6618dc5..de72895 100644 --- a/7.3/php/Dockerfile +++ b/7.3/php/Dockerfile @@ -8,19 +8,37 @@ WORKDIR /var/www # # +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + # install the PHP extensions we need RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ \ docker-php-ext-install gd opcache mysqli zip; \ \ pecl install xdebug-2.7.2; \ - pecl install memcached-3.1.3; + pecl install memcached-3.1.3; \ + \ + curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://getcomposer.org/installer; \ + curl --silent --fail --location --retry 3 --output /tmp/installer.sig --url https://composer.github.io/installer.sig; \ + php -r " \ + \$signature = file_get_contents( '/tmp/installer.sig' ); \ + \$hash = hash( 'sha384', file_get_contents('/tmp/installer.php') ); \ + if ( \$signature !== \$hash ) { \ + unlink( '/tmp/installer.php' ); \ + unlink( '/tmp/installer.sig' ); \ + echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ + exit( 1 ); \ + }"; \ + php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer; \ + composer --ansi --version --no-interaction; \ + rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh diff --git a/7.4/php/Dockerfile b/7.4/php/Dockerfile index 1fb1c16..36ed5c8 100644 --- a/7.4/php/Dockerfile +++ b/7.4/php/Dockerfile @@ -8,19 +8,37 @@ WORKDIR /var/www # # +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + # install the PHP extensions we need RUN set -ex; \ \ apt-get update; \ \ - apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev; \ + apt-get install -y --no-install-recommends libjpeg-dev libpng-dev libzip-dev libmemcached-dev unzip; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ \ docker-php-ext-install gd opcache mysqli zip; \ \ pecl install xdebug-2.8.0beta1; \ - pecl install memcached-3.1.3; + pecl install memcached-3.1.3; \ + \ + curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://getcomposer.org/installer; \ + curl --silent --fail --location --retry 3 --output /tmp/installer.sig --url https://composer.github.io/installer.sig; \ + php -r " \ + \$signature = file_get_contents( '/tmp/installer.sig' ); \ + \$hash = hash( 'sha384', file_get_contents('/tmp/installer.php') ); \ + if ( \$signature !== \$hash ) { \ + unlink( '/tmp/installer.php' ); \ + unlink( '/tmp/installer.sig' ); \ + echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ + exit( 1 ); \ + }"; \ + php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer; \ + composer --ansi --version --no-interaction; \ + rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh diff --git a/8.0/php/Dockerfile b/8.0/php/Dockerfile index 85ef365..0b09e30 100644 --- a/8.0/php/Dockerfile +++ b/8.0/php/Dockerfile @@ -8,10 +8,32 @@ WORKDIR /var/www # # +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + # install the PHP extensions we need RUN set -ex; \ \ - docker-php-ext-install mysqli; + apt-get update; \ + \ + apt-get install -y --no-install-recommends unzip; \ + \ + docker-php-ext-install mysqli; \ + \ + curl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://getcomposer.org/installer; \ + curl --silent --fail --location --retry 3 --output /tmp/installer.sig --url https://composer.github.io/installer.sig; \ + php -r " \ + \$signature = file_get_contents( '/tmp/installer.sig' ); \ + \$hash = hash( 'sha384', file_get_contents('/tmp/installer.php') ); \ + if ( \$signature !== \$hash ) { \ + unlink( '/tmp/installer.php' ); \ + unlink( '/tmp/installer.sig' ); \ + echo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \ + exit( 1 ); \ + }"; \ + php /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer; \ + composer --ansi --version --no-interaction; \ + rm -f /tmp/installer.php /tmp/installer.sig; COPY entrypoint.sh /entrypoint.sh diff --git a/Dockerfile-php.template b/Dockerfile-php.template index 804a3b8..7fc8dfa 100644 --- a/Dockerfile-php.template +++ b/Dockerfile-php.template @@ -4,6 +4,9 @@ WORKDIR /var/www %%GENERATED_WARNING%% +ENV COMPOSER_ALLOW_SUPERUSER 1 +ENV COMPOSER_HOME /tmp + %%INSTALL_EXTENSIONS%% COPY entrypoint.sh /entrypoint.sh diff --git a/update.php b/update.php index aab74b1..917ceb0 100644 --- a/update.php +++ b/update.php @@ -29,16 +29,18 @@ 'apt' => array(), 'extensions' => array(), 'pecl_extensions' => array(), + 'composer' => false, ), 'phpunit' => 3, - 'cli' => false + 'cli' => false, ), '5.3' => array( 'php' => array( 'base_name' => 'devilbox/php-fpm-5.3:latest', - 'apt' => array(), + 'apt' => array( 'unzip' ), 'extensions' => array(), 'pecl_extensions' => array(), + 'composer' => true, ), 'phpunit' => 4, 'cli' => array( @@ -49,9 +51,10 @@ '5.4' => array( 'php' => array( 'base_name' => 'php:5.4-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip' ), 'extensions' => array( 'gd', 'mysql', 'mysqli', 'zip' ), 'pecl_extensions' => array( 'xdebug-2.4.1', 'memcached-2.2.0' ), + 'composer' => true, ), 'phpunit' => 4, 'cli' => array( @@ -62,9 +65,10 @@ '5.5' => array( 'php' => array( 'base_name' => 'php:5.5-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip' ), 'extensions' => array( 'gd', 'mysql', 'mysqli', 'zip' ), 'pecl_extensions' => array( 'xdebug-2.5.5', 'memcached-2.2.0' ), + 'composer' => true, ), 'phpunit' => 4, 'cli' => array( @@ -75,9 +79,10 @@ '5.6' => array( 'php' => array( 'base_name' => 'php:5.6-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip' ), 'extensions' => array( 'gd', 'mysql', 'mysqli', 'zip' ), 'pecl_extensions' => array( 'xdebug-2.5.5', 'memcached-2.2.0' ), + 'composer' => true, ), 'phpunit' => 5, 'cli' => array( @@ -88,9 +93,10 @@ '7.0' => array( 'php' => array( 'base_name' => 'php:7.0-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip' ), 'extensions' => array( 'gd', 'opcache', 'mysqli', 'zip' ), 'pecl_extensions' => array( 'xdebug-2.7.2', 'memcached-3.1.3' ), + 'composer' => true, ), 'phpunit' => 6, 'cli' => array( @@ -101,9 +107,10 @@ '7.1' => array( 'php' => array( 'base_name' => 'php:7.1-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip' ), 'extensions' => array( 'gd', 'opcache', 'mysqli', 'zip' ), 'pecl_extensions' => array( 'xdebug-2.7.2', 'memcached-3.1.3' ), + 'composer' => true, ), 'phpunit' => 7, 'cli' => array( @@ -114,9 +121,10 @@ '7.2' => array( 'php' => array( 'base_name' => 'php:7.2-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip' ), 'extensions' => array( 'gd', 'opcache', 'mysqli', 'zip' ), 'pecl_extensions' => array( 'xdebug-2.7.2', 'memcached-3.1.3' ), + 'composer' => true, ), 'phpunit' => 7, 'cli' => array( @@ -127,9 +135,10 @@ '7.3' => array( 'php' => array( 'base_name' => 'php:7.3-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip' ), 'extensions' => array( 'gd', 'opcache', 'mysqli', 'zip' ), 'pecl_extensions' => array( 'xdebug-2.7.2', 'memcached-3.1.3' ), + 'composer' => true, ), 'phpunit' => 7, 'cli' => array( @@ -140,9 +149,10 @@ '7.4' => array( 'php' => array( 'base_name' => 'php:7.4-rc-fpm', - 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev' ), + 'apt' => array( 'libjpeg-dev', 'libpng-dev', 'libzip-dev', 'libmemcached-dev', 'unzip' ), 'extensions' => array( 'gd', 'opcache', 'mysqli', 'zip' ), 'pecl_extensions' => array( 'xdebug-2.8.0beta1', 'memcached-3.1.3' ), + 'composer' => true, ), 'phpunit' => 7, 'cli' => array( @@ -153,9 +163,10 @@ '8.0' => array( 'php' => array( 'base_name' => 'devilbox/php-fpm-8.0:latest', - 'apt' => array(), + 'apt' => array( 'unzip' ), 'extensions' => array( 'mysqli' ), 'pecl_extensions' => array(), + 'composer' => true, ), 'phpunit' => 7, 'cli' => array( @@ -214,7 +225,7 @@ // Replace tags inside the PHP Dockerfile template. $dockerfile = str_replace( '%%BASE_NAME%%', $config['base_name'], $dockerfile ); - if ( $config['apt'] || $config['extensions'] || $config['pecl_extensions'] ) { + if ( $config['apt'] || $config['extensions'] || $config['pecl_extensions'] || $config['composer'] ) { $install_extensions = "# install the PHP extensions we need\nRUN set -ex;"; if ( $config['apt'] ) { @@ -243,6 +254,24 @@ }, '' ); } + if ( $config['composer'] ) { + $install_extensions .= " \\\n\t\\\n"; + $install_extensions .= "\tcurl --silent --fail --location --retry 3 --output /tmp/installer.php --url https://getcomposer.org/installer; \\\n"; + $install_extensions .= "\tcurl --silent --fail --location --retry 3 --output /tmp/installer.sig --url https://composer.github.io/installer.sig; \\\n"; + $install_extensions .= "\tphp -r \" \\\n"; + $install_extensions .= "\t\t\\\$signature = file_get_contents( '/tmp/installer.sig' ); \\\n"; + $install_extensions .= "\t\t\\\$hash = hash( 'sha384', file_get_contents('/tmp/installer.php') ); \\\n"; + $install_extensions .= "\t\tif ( \\\$signature !== \\\$hash ) { \\\n"; + $install_extensions .= "\t\t\tunlink( '/tmp/installer.php' ); \\\n"; + $install_extensions .= "\t\t\tunlink( '/tmp/installer.sig' ); \\\n"; + $install_extensions .= "\t\t\techo 'Integrity check failed, installer is either corrupt or worse.' . PHP_EOL; \\\n"; + $install_extensions .= "\t\t\texit( 1 ); \\\n"; + $install_extensions .= "\t\t}\"; \\\n"; + $install_extensions .= "\tphp /tmp/installer.php --no-ansi --install-dir=/usr/bin --filename=composer; \\\n"; + $install_extensions .= "\tcomposer --ansi --version --no-interaction; \\\n"; + $install_extensions .= "\trm -f /tmp/installer.php /tmp/installer.sig;"; + } + $dockerfile = str_replace( '%%INSTALL_EXTENSIONS%%', $install_extensions, $dockerfile ); }