diff --git a/7/apache/Dockerfile b/7/apache-buster/Dockerfile similarity index 91% rename from 7/apache/Dockerfile rename to 7/apache-buster/Dockerfile index 1324f16f..a3f5f995 100644 --- a/7/apache/Dockerfile +++ b/7/apache-buster/Dockerfile @@ -1,6 +1,5 @@ # from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements FROM php:7.4-apache-buster -# TODO switch to buster once https://github.com/docker-library/php/issues/865 is resolved in a clean way (either in the PHP image or in PHP itself) # install the PHP extensions we need RUN set -eux; \ @@ -57,8 +56,6 @@ RUN { \ echo 'opcache.fast_shutdown=1'; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini -WORKDIR /var/www/html - # https://www.drupal.org/node/3060/release ENV DRUPAL_VERSION 7.72 ENV DRUPAL_MD5 ed967195ce0e78bf2ab7245aaf0649d6 diff --git a/7/fpm-alpine/Dockerfile b/7/fpm-alpine3.12/Dockerfile similarity index 97% rename from 7/fpm-alpine/Dockerfile rename to 7/fpm-alpine3.12/Dockerfile index 5629e8ac..2cd203f0 100644 --- a/7/fpm-alpine/Dockerfile +++ b/7/fpm-alpine3.12/Dockerfile @@ -1,5 +1,5 @@ # from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements -FROM php:7.4-fpm-alpine +FROM php:7.4-fpm-alpine3.12 # install the PHP extensions we need # postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642 @@ -46,8 +46,6 @@ RUN { \ echo 'opcache.fast_shutdown=1'; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini -WORKDIR /var/www/html - # https://www.drupal.org/node/3060/release ENV DRUPAL_VERSION 7.72 ENV DRUPAL_MD5 ed967195ce0e78bf2ab7245aaf0649d6 diff --git a/7/fpm/Dockerfile b/7/fpm-buster/Dockerfile similarity index 91% rename from 7/fpm/Dockerfile rename to 7/fpm-buster/Dockerfile index 9f5b8baf..e3104fde 100644 --- a/7/fpm/Dockerfile +++ b/7/fpm-buster/Dockerfile @@ -1,6 +1,5 @@ # from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements FROM php:7.4-fpm-buster -# TODO switch to buster once https://github.com/docker-library/php/issues/865 is resolved in a clean way (either in the PHP image or in PHP itself) # install the PHP extensions we need RUN set -eux; \ @@ -57,8 +56,6 @@ RUN { \ echo 'opcache.fast_shutdown=1'; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini -WORKDIR /var/www/html - # https://www.drupal.org/node/3060/release ENV DRUPAL_VERSION 7.72 ENV DRUPAL_MD5 ed967195ce0e78bf2ab7245aaf0649d6 diff --git a/8.8/apache/Dockerfile b/8.8/apache-buster/Dockerfile similarity index 76% rename from 8.8/apache/Dockerfile rename to 8.8/apache-buster/Dockerfile index f5a149a4..035909e0 100644 --- a/8.8/apache/Dockerfile +++ b/8.8/apache-buster/Dockerfile @@ -1,6 +1,5 @@ # from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements FROM php:7.4-apache-buster -# TODO switch to buster once https://github.com/docker-library/php/issues/865 is resolved in a clean way (either in the PHP image or in PHP itself) # install the PHP extensions we need RUN set -eux; \ @@ -57,17 +56,20 @@ RUN { \ echo 'opcache.fast_shutdown=1'; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini -WORKDIR /var/www/html +# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053 +COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/ # https://www.drupal.org/node/3060/release ENV DRUPAL_VERSION 8.8.8 -ENV DRUPAL_MD5 c8265f0228ca0306de7b2755e4731a3d +WORKDIR /opt/drupal RUN set -eux; \ - 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 + export COMPOSER_HOME="$(mktemp -d)"; \ + composer create-project --no-interaction "drupal/recommended-project:$DRUPAL_VERSION" ./; \ + chown -R www-data:www-data web/sites web/modules web/themes; \ + rmdir /var/www/html; \ + ln -sf /opt/drupal/web /var/www/html; \ + # delete composer cache + rm -rf "$COMPOSER_HOME" # vim:set ft=dockerfile: diff --git a/8.8/fpm-alpine/Dockerfile b/8.8/fpm-alpine3.12/Dockerfile similarity index 73% rename from 8.8/fpm-alpine/Dockerfile rename to 8.8/fpm-alpine3.12/Dockerfile index bf363111..ccb0c545 100644 --- a/8.8/fpm-alpine/Dockerfile +++ b/8.8/fpm-alpine3.12/Dockerfile @@ -1,5 +1,5 @@ # from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements -FROM php:7.4-fpm-alpine +FROM php:7.4-fpm-alpine3.12 # install the PHP extensions we need # postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642 @@ -46,17 +46,20 @@ RUN { \ echo 'opcache.fast_shutdown=1'; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini -WORKDIR /var/www/html +# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053 +COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/ # https://www.drupal.org/node/3060/release ENV DRUPAL_VERSION 8.8.8 -ENV DRUPAL_MD5 c8265f0228ca0306de7b2755e4731a3d +WORKDIR /opt/drupal RUN set -eux; \ - 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 + export COMPOSER_HOME="$(mktemp -d)"; \ + composer create-project --no-interaction "drupal/recommended-project:$DRUPAL_VERSION" ./; \ + chown -R www-data:www-data web/sites web/modules web/themes; \ + rmdir /var/www/html; \ + ln -sf /opt/drupal/web /var/www/html; \ + # delete composer cache + rm -rf "$COMPOSER_HOME" # vim:set ft=dockerfile: diff --git a/8.8/fpm-buster/Dockerfile b/8.8/fpm-buster/Dockerfile new file mode 100644 index 00000000..bd567c08 --- /dev/null +++ b/8.8/fpm-buster/Dockerfile @@ -0,0 +1,75 @@ +# from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements +FROM php:7.4-fpm-buster + +# install the PHP extensions we need +RUN set -eux; \ + \ + if command -v a2enmod; then \ + a2enmod rewrite; \ + fi; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libfreetype6-dev \ + libjpeg-dev \ + libpng-dev \ + libpq-dev \ + libzip-dev \ + ; \ + \ + docker-php-ext-configure gd \ + --with-freetype \ + --with-jpeg=/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'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini + +# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053 +COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/ + +# https://www.drupal.org/node/3060/release +ENV DRUPAL_VERSION 8.8.8 + +WORKDIR /opt/drupal +RUN set -eux; \ + export COMPOSER_HOME="$(mktemp -d)"; \ + composer create-project --no-interaction "drupal/recommended-project:$DRUPAL_VERSION" ./; \ + chown -R www-data:www-data web/sites web/modules web/themes; \ + rmdir /var/www/html; \ + ln -sf /opt/drupal/web /var/www/html; \ + # delete composer cache + rm -rf "$COMPOSER_HOME" + +# vim:set ft=dockerfile: diff --git a/8.9/apache/Dockerfile b/8.9/apache-buster/Dockerfile similarity index 76% rename from 8.9/apache/Dockerfile rename to 8.9/apache-buster/Dockerfile index dd528003..1738b432 100644 --- a/8.9/apache/Dockerfile +++ b/8.9/apache-buster/Dockerfile @@ -1,6 +1,5 @@ # from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements FROM php:7.4-apache-buster -# TODO switch to buster once https://github.com/docker-library/php/issues/865 is resolved in a clean way (either in the PHP image or in PHP itself) # install the PHP extensions we need RUN set -eux; \ @@ -57,17 +56,20 @@ RUN { \ echo 'opcache.fast_shutdown=1'; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini -WORKDIR /var/www/html +# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053 +COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/ # https://www.drupal.org/node/3060/release ENV DRUPAL_VERSION 8.9.2 -ENV DRUPAL_MD5 f3f64fbef97831efd1c943f392975f45 +WORKDIR /opt/drupal RUN set -eux; \ - 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 + export COMPOSER_HOME="$(mktemp -d)"; \ + composer create-project --no-interaction "drupal/recommended-project:$DRUPAL_VERSION" ./; \ + chown -R www-data:www-data web/sites web/modules web/themes; \ + rmdir /var/www/html; \ + ln -sf /opt/drupal/web /var/www/html; \ + # delete composer cache + rm -rf "$COMPOSER_HOME" # vim:set ft=dockerfile: diff --git a/8.9/fpm-alpine3.12/Dockerfile b/8.9/fpm-alpine3.12/Dockerfile new file mode 100644 index 00000000..f9f93277 --- /dev/null +++ b/8.9/fpm-alpine3.12/Dockerfile @@ -0,0 +1,65 @@ +# from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements +FROM php:7.4-fpm-alpine3.12 + +# install the PHP extensions we need +# postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642 +RUN set -eux; \ + \ + apk add --no-cache --virtual .build-deps \ + coreutils \ + freetype-dev \ + libjpeg-turbo-dev \ + libpng-dev \ + libzip-dev \ + postgresql-dev \ + ; \ + \ + docker-php-ext-configure gd \ + --with-freetype \ + --with-jpeg=/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'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini + +# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053 +COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/ + +# https://www.drupal.org/node/3060/release +ENV DRUPAL_VERSION 8.9.2 + +WORKDIR /opt/drupal +RUN set -eux; \ + export COMPOSER_HOME="$(mktemp -d)"; \ + composer create-project --no-interaction "drupal/recommended-project:$DRUPAL_VERSION" ./; \ + chown -R www-data:www-data web/sites web/modules web/themes; \ + rmdir /var/www/html; \ + ln -sf /opt/drupal/web /var/www/html; \ + # delete composer cache + rm -rf "$COMPOSER_HOME" + +# vim:set ft=dockerfile: diff --git a/8.9/fpm/Dockerfile b/8.9/fpm-buster/Dockerfile similarity index 76% rename from 8.9/fpm/Dockerfile rename to 8.9/fpm-buster/Dockerfile index 2ea1d611..7b857bb9 100644 --- a/8.9/fpm/Dockerfile +++ b/8.9/fpm-buster/Dockerfile @@ -1,6 +1,5 @@ # from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements FROM php:7.4-fpm-buster -# TODO switch to buster once https://github.com/docker-library/php/issues/865 is resolved in a clean way (either in the PHP image or in PHP itself) # install the PHP extensions we need RUN set -eux; \ @@ -57,17 +56,20 @@ RUN { \ echo 'opcache.fast_shutdown=1'; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini -WORKDIR /var/www/html +# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053 +COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/ # https://www.drupal.org/node/3060/release ENV DRUPAL_VERSION 8.9.2 -ENV DRUPAL_MD5 f3f64fbef97831efd1c943f392975f45 +WORKDIR /opt/drupal RUN set -eux; \ - 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 + export COMPOSER_HOME="$(mktemp -d)"; \ + composer create-project --no-interaction "drupal/recommended-project:$DRUPAL_VERSION" ./; \ + chown -R www-data:www-data web/sites web/modules web/themes; \ + rmdir /var/www/html; \ + ln -sf /opt/drupal/web /var/www/html; \ + # delete composer cache + rm -rf "$COMPOSER_HOME" # vim:set ft=dockerfile: diff --git a/9.0/apache-buster/Dockerfile b/9.0/apache-buster/Dockerfile new file mode 100644 index 00000000..e2f08743 --- /dev/null +++ b/9.0/apache-buster/Dockerfile @@ -0,0 +1,75 @@ +# from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements +FROM php:7.4-apache-buster + +# install the PHP extensions we need +RUN set -eux; \ + \ + if command -v a2enmod; then \ + a2enmod rewrite; \ + fi; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libfreetype6-dev \ + libjpeg-dev \ + libpng-dev \ + libpq-dev \ + libzip-dev \ + ; \ + \ + docker-php-ext-configure gd \ + --with-freetype \ + --with-jpeg=/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'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini + +# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053 +COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/ + +# https://www.drupal.org/node/3060/release +ENV DRUPAL_VERSION 9.0.2 + +WORKDIR /opt/drupal +RUN set -eux; \ + export COMPOSER_HOME="$(mktemp -d)"; \ + composer create-project --no-interaction "drupal/recommended-project:$DRUPAL_VERSION" ./; \ + chown -R www-data:www-data web/sites web/modules web/themes; \ + rmdir /var/www/html; \ + ln -sf /opt/drupal/web /var/www/html; \ + # delete composer cache + rm -rf "$COMPOSER_HOME" + +# vim:set ft=dockerfile: diff --git a/9.0/fpm-alpine3.12/Dockerfile b/9.0/fpm-alpine3.12/Dockerfile new file mode 100644 index 00000000..1f1ec0b1 --- /dev/null +++ b/9.0/fpm-alpine3.12/Dockerfile @@ -0,0 +1,65 @@ +# from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements +FROM php:7.4-fpm-alpine3.12 + +# install the PHP extensions we need +# postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642 +RUN set -eux; \ + \ + apk add --no-cache --virtual .build-deps \ + coreutils \ + freetype-dev \ + libjpeg-turbo-dev \ + libpng-dev \ + libzip-dev \ + postgresql-dev \ + ; \ + \ + docker-php-ext-configure gd \ + --with-freetype \ + --with-jpeg=/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'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini + +# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053 +COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/ + +# https://www.drupal.org/node/3060/release +ENV DRUPAL_VERSION 9.0.2 + +WORKDIR /opt/drupal +RUN set -eux; \ + export COMPOSER_HOME="$(mktemp -d)"; \ + composer create-project --no-interaction "drupal/recommended-project:$DRUPAL_VERSION" ./; \ + chown -R www-data:www-data web/sites web/modules web/themes; \ + rmdir /var/www/html; \ + ln -sf /opt/drupal/web /var/www/html; \ + # delete composer cache + rm -rf "$COMPOSER_HOME" + +# vim:set ft=dockerfile: diff --git a/9.0/fpm-buster/Dockerfile b/9.0/fpm-buster/Dockerfile new file mode 100644 index 00000000..3365da19 --- /dev/null +++ b/9.0/fpm-buster/Dockerfile @@ -0,0 +1,75 @@ +# from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements +FROM php:7.4-fpm-buster + +# install the PHP extensions we need +RUN set -eux; \ + \ + if command -v a2enmod; then \ + a2enmod rewrite; \ + fi; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libfreetype6-dev \ + libjpeg-dev \ + libpng-dev \ + libpq-dev \ + libzip-dev \ + ; \ + \ + docker-php-ext-configure gd \ + --with-freetype \ + --with-jpeg=/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'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini + +# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053 +COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/ + +# https://www.drupal.org/node/3060/release +ENV DRUPAL_VERSION 9.0.2 + +WORKDIR /opt/drupal +RUN set -eux; \ + export COMPOSER_HOME="$(mktemp -d)"; \ + composer create-project --no-interaction "drupal/recommended-project:$DRUPAL_VERSION" ./; \ + chown -R www-data:www-data web/sites web/modules web/themes; \ + rmdir /var/www/html; \ + ln -sf /opt/drupal/web /var/www/html; \ + # delete composer cache + rm -rf "$COMPOSER_HOME" + +# vim:set ft=dockerfile: diff --git a/8.9/fpm-alpine/Dockerfile b/Dockerfile-7-alpine.template similarity index 92% rename from 8.9/fpm-alpine/Dockerfile rename to Dockerfile-7-alpine.template index 2a9d1876..5dc80be0 100644 --- a/8.9/fpm-alpine/Dockerfile +++ b/Dockerfile-7-alpine.template @@ -1,5 +1,5 @@ # from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements -FROM php:7.4-fpm-alpine +FROM php:%%PHP_VERSION%% # install the PHP extensions we need # postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642 @@ -46,11 +46,9 @@ RUN { \ echo 'opcache.fast_shutdown=1'; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini -WORKDIR /var/www/html - # https://www.drupal.org/node/3060/release -ENV DRUPAL_VERSION 8.9.2 -ENV DRUPAL_MD5 f3f64fbef97831efd1c943f392975f45 +ENV DRUPAL_VERSION %%VERSION%% +ENV DRUPAL_MD5 %%MD5%% RUN set -eux; \ curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.tar.gz" -o drupal.tar.gz; \ diff --git a/8.8/fpm/Dockerfile b/Dockerfile-7-debian.template similarity index 87% rename from 8.8/fpm/Dockerfile rename to Dockerfile-7-debian.template index 049afe40..1519758d 100644 --- a/8.8/fpm/Dockerfile +++ b/Dockerfile-7-debian.template @@ -1,6 +1,5 @@ # from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements -FROM php:7.4-fpm-buster -# TODO switch to buster once https://github.com/docker-library/php/issues/865 is resolved in a clean way (either in the PHP image or in PHP itself) +FROM php:%%PHP_VERSION%% # install the PHP extensions we need RUN set -eux; \ @@ -57,11 +56,9 @@ RUN { \ echo 'opcache.fast_shutdown=1'; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini -WORKDIR /var/www/html - # https://www.drupal.org/node/3060/release -ENV DRUPAL_VERSION 8.8.8 -ENV DRUPAL_MD5 c8265f0228ca0306de7b2755e4731a3d +ENV DRUPAL_VERSION %%VERSION%% +ENV DRUPAL_MD5 %%MD5%% RUN set -eux; \ curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.tar.gz" -o drupal.tar.gz; \ diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index 76c7ad6d..700f61e5 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -1,5 +1,5 @@ # from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements -FROM php:%%PHP_VERSION%%-%%VARIANT%% +FROM php:%%PHP_VERSION%% # install the PHP extensions we need # postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642 @@ -46,17 +46,20 @@ RUN { \ echo 'opcache.fast_shutdown=1'; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini -WORKDIR /var/www/html +# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053 +COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/ # https://www.drupal.org/node/3060/release ENV DRUPAL_VERSION %%VERSION%% -ENV DRUPAL_MD5 %%MD5%% +WORKDIR /opt/drupal RUN set -eux; \ - 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 + export COMPOSER_HOME="$(mktemp -d)"; \ + composer create-project --no-interaction "drupal/recommended-project:$DRUPAL_VERSION" ./; \ + chown -R www-data:www-data web/sites web/modules web/themes; \ + rmdir /var/www/html; \ + ln -sf /opt/drupal/web /var/www/html; \ + # delete composer cache + rm -rf "$COMPOSER_HOME" # vim:set ft=dockerfile: diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index 2084cb32..cd8a672a 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -1,6 +1,5 @@ # from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements -FROM php:%%PHP_VERSION%%-%%VARIANT%%-buster -# TODO switch to buster once https://github.com/docker-library/php/issues/865 is resolved in a clean way (either in the PHP image or in PHP itself) +FROM php:%%PHP_VERSION%% # install the PHP extensions we need RUN set -eux; \ @@ -57,17 +56,20 @@ RUN { \ echo 'opcache.fast_shutdown=1'; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini -WORKDIR /var/www/html +# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053 +COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/ # https://www.drupal.org/node/3060/release ENV DRUPAL_VERSION %%VERSION%% -ENV DRUPAL_MD5 %%MD5%% +WORKDIR /opt/drupal RUN set -eux; \ - 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 + export COMPOSER_HOME="$(mktemp -d)"; \ + composer create-project --no-interaction "drupal/recommended-project:$DRUPAL_VERSION" ./; \ + chown -R www-data:www-data web/sites web/modules web/themes; \ + rmdir /var/www/html; \ + ln -sf /opt/drupal/web /var/www/html; \ + # delete composer cache + rm -rf "$COMPOSER_HOME" # vim:set ft=dockerfile: diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index 7de52773..38506484 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -2,10 +2,17 @@ set -eu declare -A aliases=( - [8.9]='8 latest' - [8.10-rc]='rc' + [8.9]='8' + [9.0]='9 latest' + [9.1-rc]='rc' ) +defaultDebianSuite='buster' +declare -A debianSuites=( + #[9.0]='buster' +) +defaultAlpineVersion='3.12' + self="$(basename "$BASH_SOURCE")" cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" @@ -30,6 +37,9 @@ dirCommit() { $(git show HEAD:./Dockerfile | awk ' toupper($1) == "COPY" { for (i = 2; i < NF; i++) { + if ($i ~ /^--from=/) { + next + } print $i } } @@ -70,7 +80,8 @@ join() { for version in "${versions[@]}"; do rcVersion="${version%-rc}" - for variant in apache fpm fpm-alpine; do + for variant in {apache,fpm}-buster fpm-alpine3.12; do + [ -e "$version/$variant/Dockerfile" ] || continue commit="$(dirCommit "$version/$variant")" fullVersion="$(git show "$commit":"$version/$variant/Dockerfile" | awk '$1 == "ENV" && $2 == "DRUPAL_VERSION" { print $3; exit }')" @@ -86,12 +97,21 @@ for version in "${versions[@]}"; do ) variantAliases=( "${versionAliases[@]/%/-$variant}" ) + debianSuite="${debianSuites[$version]:-$defaultDebianSuite}" + case "$variant" in + *-"$debianSuite") # "-apache-buster", -> "-apache" + variantAliases+=( "${versionAliases[@]/%/-${variant%-$debianSuite}}" ) + ;; + fpm-"alpine${defaultAlpineVersion}") + variantAliases+=( "${versionAliases[@]/%/-fpm-alpine}" ) + ;; + esac variantAliases=( "${variantAliases[@]//latest-/}" ) variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/$variant/Dockerfile")" variantArches="${parentRepoToArches[$variantParent]}" - if [ "$variant" = 'apache' ]; then + if [[ "$variant" = apache-* ]]; then variantAliases+=( "${versionAliases[@]}" ) fi diff --git a/update.sh b/update.sh index a42f44fd..b4842923 100755 --- a/update.sh +++ b/update.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -eo pipefail +set -euo pipefail cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" @@ -22,8 +22,21 @@ for version in "${versions[@]}"; do if [ "$rcVersion" != "$version" ]; then rcGrepV= fi + + case "$rcVersion" in + 7|8.*) + # e.g. 7.x or 8.x + drupalRelease="${rcVersion%%.*}.x" + ;; + 9.*) + # there is no https://updates.drupal.org/release-history/drupal/9.x (or 9.0.x) + # (07/2020) current could also be used for 8.7, 8.8, 8.9, 9.0, 9.1 + drupalRelease='current' + ;; + esac + fullVersion="$( - wget -qO- "https://updates.drupal.org/release-history/drupal/${rcVersion%%.*}.x" \ + wget -qO- "https://updates.drupal.org/release-history/drupal/$drupalRelease" \ | awk -v RS='[<>]' ' $1 == "release" { release = 1; version = ""; mdhash = ""; tag = ""; next } release && $1 ~ /^version|mdhash$/ { tag = $1; next } @@ -43,19 +56,26 @@ for version in "${versions[@]}"; do md5="${fullVersion##* }" fullVersion="${fullVersion% $md5}" - echo "$version: $fullVersion ($md5)" + echo "$version: $fullVersion" - for variant in fpm-alpine fpm apache; do + for variant in {apache,fpm}-buster fpm-alpine3.12; do + [ -e "$version/$variant" ] || continue dist='debian' - if [[ "$variant" = *alpine ]]; then + if [[ "$variant" = *alpine* ]]; then dist='alpine' fi + phpImage="${phpVersions[$version]:-$defaultPhpVersion}-$variant" + template="Dockerfile-$dist.template" + if [ "$version" = '7' ]; then + # 7 has no release in drupal/recommended-project + # so its Dockerfile is based on the old template + template="Dockerfile-7-$dist.template" + fi sed -r \ - -e 's/%%PHP_VERSION%%/'"${phpVersions[$version]:-$defaultPhpVersion}"'/' \ - -e 's/%%VARIANT%%/'"$variant"'/' \ + -e 's/%%PHP_VERSION%%/'"${phpImage}"'/' \ -e 's/%%VERSION%%/'"$fullVersion"'/' \ -e 's/%%MD5%%/'"$md5"'/' \ - "./Dockerfile-$dist.template" > "$version/$variant/Dockerfile" + "$template" > "$version/$variant/Dockerfile" done done