From 62375f1731b7cc30e218113c07c2aa9b960caea9 Mon Sep 17 00:00:00 2001 From: Joe Ferguson Date: Wed, 14 Feb 2018 17:09:04 -0800 Subject: [PATCH] Templatize Dockerfiles for easier updating, fix libpng16 getting purged in stretch --- 7/apache/Dockerfile | 69 ++++++++++++++++++++++++++---------- 7/fpm-alpine/Dockerfile | 22 ++++++++++-- 7/fpm/Dockerfile | 67 +++++++++++++++++++++++++--------- 8.4/apache/Dockerfile | 54 +++++++++++++++++++--------- 8.4/fpm-alpine/Dockerfile | 9 ++++- 8.4/fpm/Dockerfile | 52 +++++++++++++++++++-------- 8.5-rc/apache/Dockerfile | 54 +++++++++++++++++++--------- 8.5-rc/fpm-alpine/Dockerfile | 9 ++++- 8.5-rc/fpm/Dockerfile | 52 +++++++++++++++++++-------- Dockerfile-alpine.template | 55 ++++++++++++++++++++++++++++ Dockerfile-debian.template | 66 ++++++++++++++++++++++++++++++++++ update.sh | 28 +++++++++++---- 12 files changed, 426 insertions(+), 111 deletions(-) create mode 100644 Dockerfile-alpine.template create mode 100644 Dockerfile-debian.template diff --git a/7/apache/Dockerfile b/7/apache/Dockerfile index e3dc8d543..2144cc45e 100644 --- a/7/apache/Dockerfile +++ b/7/apache/Dockerfile @@ -1,26 +1,55 @@ # from https://www.drupal.org/requirements/php#drupalversions FROM php:7.0-apache -RUN a2enmod rewrite - # install the PHP extensions we need -RUN set -ex \ - && buildDeps=' \ - libjpeg62-turbo-dev \ - libpng12-dev \ +RUN set -ex; \ + \ + if command -v a2enmod; then \ + a2enmod rewrite; \ + fi; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libjpeg-dev \ + libpng-dev \ libpq-dev \ - ' \ - && apt-get update && apt-get install -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \ - && docker-php-ext-configure gd \ - --with-jpeg-dir=/usr \ - --with-png-dir=/usr \ - && docker-php-ext-install -j "$(nproc)" gd mbstring pdo pdo_mysql pdo_pgsql zip \ -# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/gd.so' - libjpeg.so.62: cannot open shared object file: No such file or directory in Unknown on line 0 -# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/pdo_pgsql.so' - libpq.so.5: cannot open shared object file: No such file or directory in Unknown on line 0 - && apt-mark manual \ - libjpeg62-turbo \ - libpq5 \ - && apt-get purge -y --auto-remove $buildDeps + ; \ + \ + docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +# set recommended PHP.ini settings +# see https://secure.php.net/manual/en/opcache.installation.php +RUN { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=60'; \ + echo 'opcache.fast_shutdown=1'; \ + echo 'opcache.enable_cli=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini WORKDIR /var/www/html @@ -32,4 +61,6 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta && echo "${DRUPAL_MD5} *drupal.tar.gz" | md5sum -c - \ && tar -xz --strip-components=1 -f drupal.tar.gz \ && rm drupal.tar.gz \ - && chown -R www-data:www-data sites + && chown -R www-data:www-data sites modules themes + +# vim:set ft=dockerfile: diff --git a/7/fpm-alpine/Dockerfile b/7/fpm-alpine/Dockerfile index 2b20039b6..bb03be8cb 100644 --- a/7/fpm-alpine/Dockerfile +++ b/7/fpm-alpine/Dockerfile @@ -14,7 +14,12 @@ RUN set -ex \ --with-freetype-dir=/usr/include/ \ --with-jpeg-dir=/usr/include/ \ --with-png-dir=/usr/include/ \ - && docker-php-ext-install -j "$(nproc)" gd mbstring pdo pdo_mysql pdo_pgsql zip \ + && docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + zip \ && runDeps="$( \ scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ | tr ',' '\n' \ @@ -24,6 +29,17 @@ RUN set -ex \ && apk add --virtual .drupal-phpexts-rundeps $runDeps \ && apk del .build-deps +# set recommended PHP.ini settings +# see https://secure.php.net/manual/en/opcache.installation.php +RUN { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=60'; \ + echo 'opcache.fast_shutdown=1'; \ + echo 'opcache.enable_cli=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini + WORKDIR /var/www/html # https://www.drupal.org/node/3060/release @@ -34,4 +50,6 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta && echo "${DRUPAL_MD5} *drupal.tar.gz" | md5sum -c - \ && tar -xz --strip-components=1 -f drupal.tar.gz \ && rm drupal.tar.gz \ - && chown -R www-data:www-data sites + && chown -R www-data:www-data sites modules themes + +# vim:set ft=dockerfile: diff --git a/7/fpm/Dockerfile b/7/fpm/Dockerfile index 43d9907f4..bbe7dcde4 100644 --- a/7/fpm/Dockerfile +++ b/7/fpm/Dockerfile @@ -2,23 +2,54 @@ FROM php:7.0-fpm # install the PHP extensions we need -RUN set -ex \ - && buildDeps=' \ - libjpeg62-turbo-dev \ - libpng12-dev \ +RUN set -ex; \ + \ + if command -v a2enmod; then \ + a2enmod rewrite; \ + fi; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libjpeg-dev \ + libpng-dev \ libpq-dev \ - ' \ - && apt-get update && apt-get install -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \ - && docker-php-ext-configure gd \ - --with-jpeg-dir=/usr \ - --with-png-dir=/usr \ - && docker-php-ext-install -j "$(nproc)" gd mbstring pdo pdo_mysql pdo_pgsql zip \ -# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/gd.so' - libjpeg.so.62: cannot open shared object file: No such file or directory in Unknown on line 0 -# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/pdo_pgsql.so' - libpq.so.5: cannot open shared object file: No such file or directory in Unknown on line 0 - && apt-mark manual \ - libjpeg62-turbo \ - libpq5 \ - && apt-get purge -y --auto-remove $buildDeps + ; \ + \ + docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +# set recommended PHP.ini settings +# see https://secure.php.net/manual/en/opcache.installation.php +RUN { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=60'; \ + echo 'opcache.fast_shutdown=1'; \ + echo 'opcache.enable_cli=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini WORKDIR /var/www/html @@ -30,4 +61,6 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta && echo "${DRUPAL_MD5} *drupal.tar.gz" | md5sum -c - \ && tar -xz --strip-components=1 -f drupal.tar.gz \ && rm drupal.tar.gz \ - && chown -R www-data:www-data sites + && chown -R www-data:www-data sites modules themes + +# vim:set ft=dockerfile: diff --git a/8.4/apache/Dockerfile b/8.4/apache/Dockerfile index 2cb73acd7..61ba546fa 100644 --- a/8.4/apache/Dockerfile +++ b/8.4/apache/Dockerfile @@ -1,26 +1,44 @@ # from https://www.drupal.org/requirements/php#drupalversions FROM php:7.1-apache -RUN a2enmod rewrite - # install the PHP extensions we need -RUN set -ex \ - && buildDeps=' \ - libjpeg62-turbo-dev \ +RUN set -ex; \ + \ + if command -v a2enmod; then \ + a2enmod rewrite; \ + fi; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libjpeg-dev \ libpng-dev \ libpq-dev \ - ' \ - && apt-get update && apt-get install -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \ - && docker-php-ext-configure gd \ - --with-jpeg-dir=/usr \ - --with-png-dir=/usr \ - && docker-php-ext-install -j "$(nproc)" gd mbstring opcache pdo pdo_mysql pdo_pgsql zip \ -# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/gd.so' - libjpeg.so.62: cannot open shared object file: No such file or directory in Unknown on line 0 -# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/pdo_pgsql.so' - libpq.so.5: cannot open shared object file: No such file or directory in Unknown on line 0 - && apt-mark manual \ - libjpeg62-turbo \ - libpq5 \ - && apt-get purge -y --auto-remove $buildDeps + ; \ + \ + docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* # set recommended PHP.ini settings # see https://secure.php.net/manual/en/opcache.installation.php @@ -44,3 +62,5 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta && tar -xz --strip-components=1 -f drupal.tar.gz \ && rm drupal.tar.gz \ && chown -R www-data:www-data sites modules themes + +# vim:set ft=dockerfile: diff --git a/8.4/fpm-alpine/Dockerfile b/8.4/fpm-alpine/Dockerfile index 67082faea..d5db66ee4 100644 --- a/8.4/fpm-alpine/Dockerfile +++ b/8.4/fpm-alpine/Dockerfile @@ -14,7 +14,12 @@ RUN set -ex \ --with-freetype-dir=/usr/include/ \ --with-jpeg-dir=/usr/include/ \ --with-png-dir=/usr/include/ \ - && docker-php-ext-install -j "$(nproc)" gd mbstring opcache pdo pdo_mysql pdo_pgsql zip \ + && docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + zip \ && runDeps="$( \ scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ | tr ',' '\n' \ @@ -46,3 +51,5 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta && tar -xz --strip-components=1 -f drupal.tar.gz \ && rm drupal.tar.gz \ && chown -R www-data:www-data sites modules themes + +# vim:set ft=dockerfile: diff --git a/8.4/fpm/Dockerfile b/8.4/fpm/Dockerfile index 6cd136263..ed5d3b28d 100644 --- a/8.4/fpm/Dockerfile +++ b/8.4/fpm/Dockerfile @@ -2,23 +2,43 @@ FROM php:7.1-fpm # install the PHP extensions we need -RUN set -ex \ - && buildDeps=' \ - libjpeg62-turbo-dev \ +RUN set -ex; \ + \ + if command -v a2enmod; then \ + a2enmod rewrite; \ + fi; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libjpeg-dev \ libpng-dev \ libpq-dev \ - ' \ - && apt-get update && apt-get install -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \ - && docker-php-ext-configure gd \ - --with-jpeg-dir=/usr \ - --with-png-dir=/usr \ - && docker-php-ext-install -j "$(nproc)" gd mbstring opcache pdo pdo_mysql pdo_pgsql zip \ -# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/gd.so' - libjpeg.so.62: cannot open shared object file: No such file or directory in Unknown on line 0 -# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/pdo_pgsql.so' - libpq.so.5: cannot open shared object file: No such file or directory in Unknown on line 0 - && apt-mark manual \ - libjpeg62-turbo \ - libpq5 \ - && apt-get purge -y --auto-remove $buildDeps + ; \ + \ + docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* # set recommended PHP.ini settings # see https://secure.php.net/manual/en/opcache.installation.php @@ -42,3 +62,5 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta && tar -xz --strip-components=1 -f drupal.tar.gz \ && rm drupal.tar.gz \ && chown -R www-data:www-data sites modules themes + +# vim:set ft=dockerfile: diff --git a/8.5-rc/apache/Dockerfile b/8.5-rc/apache/Dockerfile index f0d5b0b5f..5787d5818 100644 --- a/8.5-rc/apache/Dockerfile +++ b/8.5-rc/apache/Dockerfile @@ -1,26 +1,44 @@ # from https://www.drupal.org/requirements/php#drupalversions FROM php:7.2-apache -RUN a2enmod rewrite - # install the PHP extensions we need -RUN set -ex \ - && buildDeps=' \ - libjpeg62-turbo-dev \ +RUN set -ex; \ + \ + if command -v a2enmod; then \ + a2enmod rewrite; \ + fi; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libjpeg-dev \ libpng-dev \ libpq-dev \ - ' \ - && apt-get update && apt-get install -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \ - && docker-php-ext-configure gd \ - --with-jpeg-dir=/usr \ - --with-png-dir=/usr \ - && docker-php-ext-install -j "$(nproc)" gd mbstring opcache pdo pdo_mysql pdo_pgsql zip \ -# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/gd.so' - libjpeg.so.62: cannot open shared object file: No such file or directory in Unknown on line 0 -# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/pdo_pgsql.so' - libpq.so.5: cannot open shared object file: No such file or directory in Unknown on line 0 - && apt-mark manual \ - libjpeg62-turbo \ - libpq5 \ - && apt-get purge -y --auto-remove $buildDeps + ; \ + \ + docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* # set recommended PHP.ini settings # see https://secure.php.net/manual/en/opcache.installation.php @@ -44,3 +62,5 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta && tar -xz --strip-components=1 -f drupal.tar.gz \ && rm drupal.tar.gz \ && chown -R www-data:www-data sites modules themes + +# vim:set ft=dockerfile: diff --git a/8.5-rc/fpm-alpine/Dockerfile b/8.5-rc/fpm-alpine/Dockerfile index 093627ca4..82d32b448 100644 --- a/8.5-rc/fpm-alpine/Dockerfile +++ b/8.5-rc/fpm-alpine/Dockerfile @@ -14,7 +14,12 @@ RUN set -ex \ --with-freetype-dir=/usr/include/ \ --with-jpeg-dir=/usr/include/ \ --with-png-dir=/usr/include/ \ - && docker-php-ext-install -j "$(nproc)" gd mbstring opcache pdo pdo_mysql pdo_pgsql zip \ + && docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + zip \ && runDeps="$( \ scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ | tr ',' '\n' \ @@ -46,3 +51,5 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta && tar -xz --strip-components=1 -f drupal.tar.gz \ && rm drupal.tar.gz \ && chown -R www-data:www-data sites modules themes + +# vim:set ft=dockerfile: diff --git a/8.5-rc/fpm/Dockerfile b/8.5-rc/fpm/Dockerfile index 7d6792254..92b823682 100644 --- a/8.5-rc/fpm/Dockerfile +++ b/8.5-rc/fpm/Dockerfile @@ -2,23 +2,43 @@ FROM php:7.2-fpm # install the PHP extensions we need -RUN set -ex \ - && buildDeps=' \ - libjpeg62-turbo-dev \ +RUN set -ex; \ + \ + if command -v a2enmod; then \ + a2enmod rewrite; \ + fi; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libjpeg-dev \ libpng-dev \ libpq-dev \ - ' \ - && apt-get update && apt-get install -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \ - && docker-php-ext-configure gd \ - --with-jpeg-dir=/usr \ - --with-png-dir=/usr \ - && docker-php-ext-install -j "$(nproc)" gd mbstring opcache pdo pdo_mysql pdo_pgsql zip \ -# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/gd.so' - libjpeg.so.62: cannot open shared object file: No such file or directory in Unknown on line 0 -# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/pdo_pgsql.so' - libpq.so.5: cannot open shared object file: No such file or directory in Unknown on line 0 - && apt-mark manual \ - libjpeg62-turbo \ - libpq5 \ - && apt-get purge -y --auto-remove $buildDeps + ; \ + \ + docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* # set recommended PHP.ini settings # see https://secure.php.net/manual/en/opcache.installation.php @@ -42,3 +62,5 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta && tar -xz --strip-components=1 -f drupal.tar.gz \ && rm drupal.tar.gz \ && chown -R www-data:www-data sites modules themes + +# vim:set ft=dockerfile: diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template new file mode 100644 index 000000000..060aa718b --- /dev/null +++ b/Dockerfile-alpine.template @@ -0,0 +1,55 @@ +# from https://www.drupal.org/requirements/php#drupalversions +FROM php:%%PHP_VERSION%%-%%VARIANT%% + +# install the PHP extensions we need +# postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642 +RUN set -ex \ + && apk add --no-cache --virtual .build-deps \ + coreutils \ + freetype-dev \ + libjpeg-turbo-dev \ + libpng-dev \ + postgresql-dev \ + && docker-php-ext-configure gd \ + --with-freetype-dir=/usr/include/ \ + --with-jpeg-dir=/usr/include/ \ + --with-png-dir=/usr/include/ \ + && docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + zip \ + && runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )" \ + && apk add --virtual .drupal-phpexts-rundeps $runDeps \ + && apk del .build-deps + +# set recommended PHP.ini settings +# see https://secure.php.net/manual/en/opcache.installation.php +RUN { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=60'; \ + echo 'opcache.fast_shutdown=1'; \ + echo 'opcache.enable_cli=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini + +WORKDIR /var/www/html + +# https://www.drupal.org/node/3060/release +ENV DRUPAL_VERSION %%VERSION%% +ENV DRUPAL_MD5 %%MD5%% + +RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.tar.gz" -o drupal.tar.gz \ + && echo "${DRUPAL_MD5} *drupal.tar.gz" | md5sum -c - \ + && tar -xz --strip-components=1 -f drupal.tar.gz \ + && rm drupal.tar.gz \ + && chown -R www-data:www-data sites modules themes + +# vim:set ft=dockerfile: diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template new file mode 100644 index 000000000..90fc49fe3 --- /dev/null +++ b/Dockerfile-debian.template @@ -0,0 +1,66 @@ +# from https://www.drupal.org/requirements/php#drupalversions +FROM php:%%PHP_VERSION%%-%%VARIANT%% + +# install the PHP extensions we need +RUN set -ex; \ + \ + if command -v a2enmod; then \ + a2enmod rewrite; \ + fi; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libjpeg-dev \ + libpng-dev \ + libpq-dev \ + ; \ + \ + docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +# set recommended PHP.ini settings +# see https://secure.php.net/manual/en/opcache.installation.php +RUN { \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=4000'; \ + echo 'opcache.revalidate_freq=60'; \ + echo 'opcache.fast_shutdown=1'; \ + echo 'opcache.enable_cli=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini + +WORKDIR /var/www/html + +# https://www.drupal.org/node/3060/release +ENV DRUPAL_VERSION %%VERSION%% +ENV DRUPAL_MD5 %%MD5%% + +RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.tar.gz" -o drupal.tar.gz \ + && echo "${DRUPAL_MD5} *drupal.tar.gz" | md5sum -c - \ + && tar -xz --strip-components=1 -f drupal.tar.gz \ + && rm drupal.tar.gz \ + && chown -R www-data:www-data sites modules themes + +# vim:set ft=dockerfile: diff --git a/update.sh b/update.sh index aa7ee094a..93f00afb1 100755 --- a/update.sh +++ b/update.sh @@ -9,6 +9,12 @@ if [ ${#versions[@]} -eq 0 ]; then fi versions=( "${versions[@]%/}" ) +declare -A phpVersions=( + [7]='7.0' + [8.4]='7.1' + [8.5-rc]='7.2' +) + curl -fsSL 'https://www.drupal.org/node/3060/release' -o release trap 'rm -f release' EXIT @@ -31,15 +37,23 @@ for version in "${versions[@]}"; do fi md5="$(grep -A6 -m1 '>drupal-'"$fullVersion"'.tar.gz<' release | grep -A1 -m1 '"md5 hash"' | tail -1 | awk '{ print $1 }')" - ( - set -x - sed -ri ' - s/^(ENV DRUPAL_VERSION) .*/\1 '"$fullVersion"'/; - s/^(ENV DRUPAL_MD5) .*/\1 '"$md5"'/; - ' "$version"/*/Dockerfile - ) for variant in fpm-alpine fpm apache; do + dist='debian' + if [[ "$variant" = *alpine ]]; then + dist='alpine' + fi + + ( + set -x + sed -r \ + -e 's/%%PHP_VERSION%%/'"${phpVersions[$version]}"'/' \ + -e 's/%%VARIANT%%/'"$variant"'/' \ + -e 's/%%VERSION%%/'"$fullVersion"'/' \ + -e 's/%%MD5%%/'"$md5"'/' \ + "./Dockerfile-$dist.template" > "$version/$variant/Dockerfile" + ) + travisEnv='\n - VERSION='"$version"' VARIANT='"$variant$travisEnv" done done