diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..4fed8a16d --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +/*/**/Dockerfile linguist-generated +/Dockerfile*.template linguist-language=Dockerfile diff --git a/.github/workflows/verify-templating.yml b/.github/workflows/verify-templating.yml new file mode 100644 index 000000000..7e833f1c7 --- /dev/null +++ b/.github/workflows/verify-templating.yml @@ -0,0 +1,22 @@ +name: Verify Templating + +on: + pull_request: + push: + +defaults: + run: + shell: 'bash -Eeuo pipefail -x {0}' + +jobs: + apply-templates: + name: Check For Uncomitted Changes + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Apply Templates + run: ./apply-templates.sh + - name: Check Git Status + run: | + status="$(git status --short)" + [ -z "$status" ] diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..d548f66de --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.jq-template.awk diff --git a/7/apache-buster/Dockerfile b/7/php7.4/apache-buster/Dockerfile similarity index 94% rename from 7/apache-buster/Dockerfile rename to 7/php7.4/apache-buster/Dockerfile index 9b93180f9..26d7cbc0f 100644 --- a/7/apache-buster/Dockerfile +++ b/7/php7.4/apache-buster/Dockerfile @@ -1,3 +1,9 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + # from https://www.drupal.org/docs/system-requirements/php-requirements FROM php:7.4-apache-buster diff --git a/7/fpm-alpine3.12/Dockerfile b/7/php7.4/fpm-alpine3.12/Dockerfile similarity index 88% rename from 7/fpm-alpine3.12/Dockerfile rename to 7/php7.4/fpm-alpine3.12/Dockerfile index 617579f33..122ba0ffb 100644 --- a/7/fpm-alpine3.12/Dockerfile +++ b/7/php7.4/fpm-alpine3.12/Dockerfile @@ -1,8 +1,13 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + # from https://www.drupal.org/docs/system-requirements/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 \ @@ -11,6 +16,7 @@ RUN set -eux; \ libjpeg-turbo-dev \ libpng-dev \ libzip-dev \ +# postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642 postgresql-dev \ ; \ \ @@ -33,8 +39,8 @@ RUN set -eux; \ | 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 + apk add --no-network --virtual .drupal-phpexts-rundeps $runDeps; \ + apk del --no-network .build-deps # set recommended PHP.ini settings # see https://secure.php.net/manual/en/opcache.installation.php diff --git a/7/fpm-buster/Dockerfile b/7/php7.4/fpm-buster/Dockerfile similarity index 94% rename from 7/fpm-buster/Dockerfile rename to 7/php7.4/fpm-buster/Dockerfile index f8310ddfa..7ca28065d 100644 --- a/7/fpm-buster/Dockerfile +++ b/7/php7.4/fpm-buster/Dockerfile @@ -1,3 +1,9 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + # from https://www.drupal.org/docs/system-requirements/php-requirements FROM php:7.4-fpm-buster diff --git a/8.9/apache-buster/Dockerfile b/8.9/php7.4/apache-buster/Dockerfile similarity index 95% rename from 8.9/apache-buster/Dockerfile rename to 8.9/php7.4/apache-buster/Dockerfile index b4c32fbd6..7a25c5e1a 100644 --- a/8.9/apache-buster/Dockerfile +++ b/8.9/php7.4/apache-buster/Dockerfile @@ -1,3 +1,9 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + # from https://www.drupal.org/docs/system-requirements/php-requirements FROM php:7.4-apache-buster diff --git a/8.9/fpm-alpine3.12/Dockerfile b/8.9/php7.4/fpm-alpine3.12/Dockerfile similarity index 89% rename from 8.9/fpm-alpine3.12/Dockerfile rename to 8.9/php7.4/fpm-alpine3.12/Dockerfile index 037d0061e..4f3e5df7a 100644 --- a/8.9/fpm-alpine3.12/Dockerfile +++ b/8.9/php7.4/fpm-alpine3.12/Dockerfile @@ -1,8 +1,13 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + # from https://www.drupal.org/docs/system-requirements/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 \ @@ -11,6 +16,7 @@ RUN set -eux; \ libjpeg-turbo-dev \ libpng-dev \ libzip-dev \ +# postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642 postgresql-dev \ ; \ \ @@ -33,8 +39,8 @@ RUN set -eux; \ | 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 + apk add --no-network --virtual .drupal-phpexts-rundeps $runDeps; \ + apk del --no-network .build-deps # set recommended PHP.ini settings # see https://secure.php.net/manual/en/opcache.installation.php diff --git a/8.9/fpm-buster/Dockerfile b/8.9/php7.4/fpm-buster/Dockerfile similarity index 95% rename from 8.9/fpm-buster/Dockerfile rename to 8.9/php7.4/fpm-buster/Dockerfile index de408c0d9..ce35cee81 100644 --- a/8.9/fpm-buster/Dockerfile +++ b/8.9/php7.4/fpm-buster/Dockerfile @@ -1,3 +1,9 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + # from https://www.drupal.org/docs/system-requirements/php-requirements FROM php:7.4-fpm-buster diff --git a/9.0/apache-buster/Dockerfile b/9.0/php7.4/apache-buster/Dockerfile similarity index 95% rename from 9.0/apache-buster/Dockerfile rename to 9.0/php7.4/apache-buster/Dockerfile index 3fa3b5b29..b025da364 100644 --- a/9.0/apache-buster/Dockerfile +++ b/9.0/php7.4/apache-buster/Dockerfile @@ -1,3 +1,9 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + # from https://www.drupal.org/docs/system-requirements/php-requirements FROM php:7.4-apache-buster diff --git a/9.0/fpm-alpine3.12/Dockerfile b/9.0/php7.4/fpm-alpine3.12/Dockerfile similarity index 89% rename from 9.0/fpm-alpine3.12/Dockerfile rename to 9.0/php7.4/fpm-alpine3.12/Dockerfile index 4b320fcd8..61173ab7a 100644 --- a/9.0/fpm-alpine3.12/Dockerfile +++ b/9.0/php7.4/fpm-alpine3.12/Dockerfile @@ -1,8 +1,13 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + # from https://www.drupal.org/docs/system-requirements/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 \ @@ -11,6 +16,7 @@ RUN set -eux; \ libjpeg-turbo-dev \ libpng-dev \ libzip-dev \ +# postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642 postgresql-dev \ ; \ \ @@ -33,8 +39,8 @@ RUN set -eux; \ | 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 + apk add --no-network --virtual .drupal-phpexts-rundeps $runDeps; \ + apk del --no-network .build-deps # set recommended PHP.ini settings # see https://secure.php.net/manual/en/opcache.installation.php diff --git a/9.0/fpm-buster/Dockerfile b/9.0/php7.4/fpm-buster/Dockerfile similarity index 95% rename from 9.0/fpm-buster/Dockerfile rename to 9.0/php7.4/fpm-buster/Dockerfile index c6acb0617..4b285020b 100644 --- a/9.0/fpm-buster/Dockerfile +++ b/9.0/php7.4/fpm-buster/Dockerfile @@ -1,3 +1,9 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + # from https://www.drupal.org/docs/system-requirements/php-requirements FROM php:7.4-fpm-buster diff --git a/9.1/php7.4/apache-buster/Dockerfile b/9.1/php7.4/apache-buster/Dockerfile new file mode 100644 index 000000000..66e09b8da --- /dev/null +++ b/9.1/php7.4/apache-buster/Dockerfile @@ -0,0 +1,82 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +# from https://www.drupal.org/docs/system-requirements/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 + +COPY --from=composer:2.0 /usr/bin/composer /usr/local/bin/ + +# https://www.drupal.org/node/3060/release +ENV DRUPAL_VERSION 9.1.3 + +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" + +ENV PATH=${PATH}:/opt/drupal/vendor/bin + +# vim:set ft=dockerfile: diff --git a/Dockerfile-alpine.template b/9.1/php7.4/fpm-alpine3.12/Dockerfile similarity index 83% rename from Dockerfile-alpine.template rename to 9.1/php7.4/fpm-alpine3.12/Dockerfile index 23c14f22d..5ab649274 100644 --- a/Dockerfile-alpine.template +++ b/9.1/php7.4/fpm-alpine3.12/Dockerfile @@ -1,8 +1,13 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + # from https://www.drupal.org/docs/system-requirements/php-requirements -FROM php:%%PHP_VERSION%% +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 \ @@ -11,6 +16,7 @@ RUN set -eux; \ libjpeg-turbo-dev \ libpng-dev \ libzip-dev \ +# postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642 postgresql-dev \ ; \ \ @@ -33,8 +39,8 @@ RUN set -eux; \ | 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 + apk add --no-network --virtual .drupal-phpexts-rundeps $runDeps; \ + apk del --no-network .build-deps # set recommended PHP.ini settings # see https://secure.php.net/manual/en/opcache.installation.php @@ -46,10 +52,10 @@ RUN { \ echo 'opcache.fast_shutdown=1'; \ } > /usr/local/etc/php/conf.d/opcache-recommended.ini -COPY --from=composer:%%COMPOSER_VERSION%% /usr/bin/composer /usr/local/bin/ +COPY --from=composer:2.0 /usr/bin/composer /usr/local/bin/ # https://www.drupal.org/node/3060/release -ENV DRUPAL_VERSION %%VERSION%% +ENV DRUPAL_VERSION 9.1.3 WORKDIR /opt/drupal RUN set -eux; \ diff --git a/9.1/php7.4/fpm-buster/Dockerfile b/9.1/php7.4/fpm-buster/Dockerfile new file mode 100644 index 000000000..76d59e5dc --- /dev/null +++ b/9.1/php7.4/fpm-buster/Dockerfile @@ -0,0 +1,82 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + +# from https://www.drupal.org/docs/system-requirements/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 + +COPY --from=composer:2.0 /usr/bin/composer /usr/local/bin/ + +# https://www.drupal.org/node/3060/release +ENV DRUPAL_VERSION 9.1.3 + +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" + +ENV PATH=${PATH}:/opt/drupal/vendor/bin + +# vim:set ft=dockerfile: diff --git a/9.1/apache-buster/Dockerfile b/9.1/php8.0/apache-buster/Dockerfile similarity index 95% rename from 9.1/apache-buster/Dockerfile rename to 9.1/php8.0/apache-buster/Dockerfile index f687b7cde..87ce00715 100644 --- a/9.1/apache-buster/Dockerfile +++ b/9.1/php8.0/apache-buster/Dockerfile @@ -1,3 +1,9 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + # from https://www.drupal.org/docs/system-requirements/php-requirements FROM php:8.0-apache-buster diff --git a/9.1/fpm-alpine3.12/Dockerfile b/9.1/php8.0/fpm-alpine3.12/Dockerfile similarity index 89% rename from 9.1/fpm-alpine3.12/Dockerfile rename to 9.1/php8.0/fpm-alpine3.12/Dockerfile index a808059f8..056637f48 100644 --- a/9.1/fpm-alpine3.12/Dockerfile +++ b/9.1/php8.0/fpm-alpine3.12/Dockerfile @@ -1,8 +1,13 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + # from https://www.drupal.org/docs/system-requirements/php-requirements FROM php:8.0-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 \ @@ -11,6 +16,7 @@ RUN set -eux; \ libjpeg-turbo-dev \ libpng-dev \ libzip-dev \ +# postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642 postgresql-dev \ ; \ \ @@ -33,8 +39,8 @@ RUN set -eux; \ | 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 + apk add --no-network --virtual .drupal-phpexts-rundeps $runDeps; \ + apk del --no-network .build-deps # set recommended PHP.ini settings # see https://secure.php.net/manual/en/opcache.installation.php diff --git a/9.1/fpm-buster/Dockerfile b/9.1/php8.0/fpm-buster/Dockerfile similarity index 95% rename from 9.1/fpm-buster/Dockerfile rename to 9.1/php8.0/fpm-buster/Dockerfile index abb50f7bb..3477c8c6a 100644 --- a/9.1/fpm-buster/Dockerfile +++ b/9.1/php8.0/fpm-buster/Dockerfile @@ -1,3 +1,9 @@ +# +# NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" +# +# PLEASE DO NOT EDIT IT DIRECTLY. +# + # from https://www.drupal.org/docs/system-requirements/php-requirements FROM php:8.0-fpm-buster diff --git a/Dockerfile-7-alpine.template b/Dockerfile-7-alpine.template deleted file mode 100644 index f8c3e7744..000000000 --- a/Dockerfile-7-alpine.template +++ /dev/null @@ -1,60 +0,0 @@ -# from https://www.drupal.org/docs/system-requirements/php-requirements -FROM php:%%PHP_VERSION%% - -# 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://www.drupal.org/node/3060/release -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; \ - 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-7-debian.template b/Dockerfile-7-debian.template deleted file mode 100644 index 82dc4cc8e..000000000 --- a/Dockerfile-7-debian.template +++ /dev/null @@ -1,70 +0,0 @@ -# from https://www.drupal.org/docs/system-requirements/php-requirements -FROM php:%%PHP_VERSION%% - -# 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://www.drupal.org/node/3060/release -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; \ - 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 deleted file mode 100644 index 0d5061545..000000000 --- a/Dockerfile-debian.template +++ /dev/null @@ -1,76 +0,0 @@ -# from https://www.drupal.org/docs/system-requirements/php-requirements -FROM php:%%PHP_VERSION%% - -# 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 - -COPY --from=composer:%%COMPOSER_VERSION%% /usr/bin/composer /usr/local/bin/ - -# https://www.drupal.org/node/3060/release -ENV DRUPAL_VERSION %%VERSION%% - -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" - -ENV PATH=${PATH}:/opt/drupal/vendor/bin - -# vim:set ft=dockerfile: diff --git a/Dockerfile.template b/Dockerfile.template new file mode 100644 index 000000000..ba22b0878 --- /dev/null +++ b/Dockerfile.template @@ -0,0 +1,115 @@ +{{ + def is_alpine: + env.variant | index("alpine") +-}} +# from https://www.drupal.org/docs/system-requirements/php-requirements +FROM php:{{ env.phpVersion }}-{{ env.variant }} + +# install the PHP extensions we need +RUN set -eux; \ + \ +{{ if is_alpine then ( -}} + apk add --no-cache --virtual .build-deps \ + coreutils \ + freetype-dev \ + libjpeg-turbo-dev \ + libpng-dev \ + libzip-dev \ +# postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642 + postgresql-dev \ +{{ ) else ( -}} + 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 \ +{{ ) end -}} + ; \ + \ + docker-php-ext-configure gd \ + --with-freetype \ + --with-jpeg={{ if is_alpine then "/usr/include" else "/usr" end }} \ + ; \ + \ + docker-php-ext-install -j "$(nproc)" \ + gd \ + opcache \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +{{ if is_alpine then ( -}} + 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 --no-network --virtual .drupal-phpexts-rundeps $runDeps; \ + apk del --no-network .build-deps +{{ ) else ( -}} +# 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/* +{{ ) end -}} + +# 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 + +{{ if env.version | startswith("7") then "" else ( -}} +COPY --from=composer:{{ .composer.version }} /usr/bin/composer /usr/local/bin/ + +{{ ) end -}} +# https://www.drupal.org/node/3060/release +ENV DRUPAL_VERSION {{ .version }} +{{ if env.version | startswith("7") then ( -}} +ENV DRUPAL_MD5 {{ .md5 }} + +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 +{{ ) else ( -}} + +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" + +ENV PATH=${PATH}:/opt/drupal/vendor/bin +{{ ) end -}} + +# vim:set ft=dockerfile: diff --git a/apply-templates.sh b/apply-templates.sh new file mode 100755 index 000000000..a8eea693b --- /dev/null +++ b/apply-templates.sh @@ -0,0 +1,54 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +[ -f versions.json ] # run "versions.sh" first + +jqt='.jq-template.awk' +if [ -n "${BASHBREW_SCRIPTS:-}" ]; then + jqt="$BASHBREW_SCRIPTS/jq-template.awk" +elif [ "$BASH_SOURCE" -nt "$jqt" ]; then + wget -qO "$jqt" 'https://github.com/docker-library/bashbrew/raw/5f0c26381fb7cc78b2d217d58007800bdcfbcfa1/scripts/jq-template.awk' +fi + +if [ "$#" -eq 0 ]; then + versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)" + eval "set -- $versions" +fi + +generated_warning() { + cat <<-EOH + # + # NOTE: THIS DOCKERFILE IS GENERATED VIA "apply-templates.sh" + # + # PLEASE DO NOT EDIT IT DIRECTLY. + # + + EOH +} + +for version; do + export version + + phpVersions="$(jq -r '.[env.version].phpVersions | map(@sh) | join(" ")' versions.json)" + eval "phpVersions=( $phpVersions )" + variants="$(jq -r '.[env.version].variants | map(@sh) | join(" ")' versions.json)" + eval "variants=( $variants )" + + for phpVersion in "${phpVersions[@]}"; do + export phpVersion + + for variant in "${variants[@]}"; do + export variant + + dir="$version/php$phpVersion/$variant" + mkdir -p "$dir" + + echo "processing $dir ..." + + { + generated_warning + gawk -f "$jqt" Dockerfile.template + } > "$dir/Dockerfile" + done + done +done diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index d99810d7b..73c5bd434 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -13,14 +13,24 @@ declare -A debianSuites=( ) defaultAlpineVersion='3.12' +defaultPhpVersion='php8.0' +declare -A defaultPhpVersions=( +# https://www.drupal.org/docs/7/system-requirements/php-requirements#php_required + [7]='php7.4' + [8.9]='php7.4' + [9.0]='php7.4' +) + self="$(basename "$BASH_SOURCE")" cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" -versions=( */ ) -versions=( "${versions[@]%/}" ) +if [ "$#" -eq 0 ]; then + versions="$(jq -r 'keys | map(@sh) | join(" ")' versions.json)" + eval "set -- $versions" +fi # sort version numbers with highest first -IFS=$'\n'; versions=( $(echo "${versions[*]}" | sort -rV) ); unset IFS +IFS=$'\n'; set -- $(sort -rV <<<"$*"); unset IFS # get the most recent commit which modified any of "$@" fileCommit() { @@ -97,63 +107,92 @@ join() { echo "${out#$sep}" } -for version in "${versions[@]}"; do - rcVersion="${version%-rc}" - for variant in {apache,fpm}-buster fpm-alpine3.12; do - [ -e "$version/$variant/Dockerfile" ] || continue - commit="$(dirCommit "$version/$variant")" +for version; do + export version - fullVersion="$(git show "$commit":"$version/$variant/Dockerfile" | awk '$1 == "ENV" && $2 == "DRUPAL_VERSION" { print $3; exit }')" + phpVersions="$(jq -r '.[env.version].phpVersions | map(@sh) | join(" ")' versions.json)" + eval "phpVersions=( $phpVersions )" + variants="$(jq -r '.[env.version].variants | map(@sh) | join(" ")' versions.json)" + eval "variants=( $variants )" - versionAliases=() - while [ "$fullVersion" != "$rcVersion" -a "${fullVersion%[.]*}" != "$fullVersion" ]; do - versionAliases+=( $fullVersion ) - fullVersion="${fullVersion%[.]*}" - done - versionAliases+=( - $version - ${aliases[$version]:-} - ) - - 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-/}" ) - - variantParents="$(gawk "$gawkParents" "$version/$variant/Dockerfile")" - variantArches= - for variantParent in $variantParents; do - parentArches="${parentRepoToArches[$variantParent]:-}" - if [ -z "$parentArches" ]; then - continue - elif [ -z "$variantArches" ]; then - variantArches="$parentArches" - else - variantArches="$( - comm -12 \ - <(xargs -n1 <<<"$variantArches" | sort -u) \ - <(xargs -n1 <<<"$parentArches" | sort -u) - )" + fullVersion="$(jq -r '.[env.version].version' versions.json)" + + rcVersion="${version%-rc}" + versionAliases=() + while [ "$fullVersion" != "$rcVersion" -a "${fullVersion%[.]*}" != "$fullVersion" ]; do + versionAliases+=( $fullVersion ) + fullVersion="${fullVersion%[.]*}" + done + versionAliases+=( + $version + ${aliases[$version]:-} + ) + + for phpVersion in "${phpVersions[@]}"; do + phpVersion="php$phpVersion" + for variant in "${variants[@]}"; do + dir="$version/$phpVersion/$variant" + [ -f "$dir/Dockerfile" ] || continue + + commit="$(dirCommit "$dir")" + + phpVersionAliases=( "${versionAliases[@]/%/-$phpVersion}" ) + phpVersionAliases=( "${phpVersionAliases[@]//latest-/}" ) + + variantSuffixes=( "$variant" ) + debianSuite="${debianSuites[$version]:-$defaultDebianSuite}" + case "$variant" in + *-"$debianSuite") # "-apache-buster", -> "-apache" + variantSuffixes+=( "${variant%-$debianSuite}" ) + ;; + fpm-"alpine${defaultAlpineVersion}") + variantSuffixes+=( fpm-alpine ) + ;; + esac + variantAliases=() + phpVersionVariantAliases=() + for variantSuffix in "${variantSuffixes[@]}"; do + variantAliases+=( "${versionAliases[@]/%/-$variantSuffix}" ) + phpVersionVariantAliases+=( "${phpVersionAliases[@]/%/-$variantSuffix}" ) + done + variantAliases=( "${variantAliases[@]//latest-/}" ) + phpVersionVariantAliases=( "${phpVersionVariantAliases[@]//latest-/}" ) + + fullAliases=() + fullAliases+=( "${phpVersionVariantAliases[@]}" ) + versionDefaultPhpVersion="${defaultPhpVersions[$version]:-$defaultPhpVersion}" + if [ "$phpVersion" = "$versionDefaultPhpVersion" ]; then + fullAliases+=( "${variantAliases[@]}" ) + if [[ "$variant" = apache-* ]]; then + fullAliases+=( "${versionAliases[@]}" ) + fullAliases+=( "${phpVersionAliases[@]}" ) + fi fi - done - if [[ "$variant" = apache-* ]]; then - variantAliases+=( "${versionAliases[@]}" ) - fi - - echo - cat <<-EOE - Tags: $(join ', ' "${variantAliases[@]}") - Architectures: $(join ', ' $variantArches) - GitCommit: $commit - Directory: $version/$variant - EOE + variantParents="$(gawk "$gawkParents" "$dir/Dockerfile")" + variantArches= + for variantParent in $variantParents; do + parentArches="${parentRepoToArches[$variantParent]:-}" + if [ -z "$parentArches" ]; then + continue + elif [ -z "$variantArches" ]; then + variantArches="$parentArches" + else + variantArches="$( + comm -12 \ + <(xargs -n1 <<<"$variantArches" | sort -u) \ + <(xargs -n1 <<<"$parentArches" | sort -u) + )" + fi + done + + echo + cat <<-EOE + Tags: $(join ', ' "${fullAliases[@]}") + Architectures: $(join ', ' $variantArches) + GitCommit: $commit + Directory: $dir + EOE + done done done diff --git a/update.sh b/update.sh index e7f35ed9b..bac2d7581 100755 --- a/update.sh +++ b/update.sh @@ -1,95 +1,7 @@ -#!/bin/bash -set -euo pipefail +#!/usr/bin/env bash +set -Eeuo pipefail cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" -versions=( "$@" ) -if [ ${#versions[@]} -eq 0 ]; then - versions=( */ ) -fi -versions=( "${versions[@]%/}" ) - -# https://www.drupal.org/docs/8/system-requirements/php-requirements#php_required -defaultPhpVersion='8.0' -declare -A phpVersions=( - # https://www.drupal.org/docs/7/system-requirements/php-requirements#php_required - [7]='7.4' - [8.9]='7.4' - [9.0]='7.4' -) - -declare -A composerVersions=( - [8.9]='1.10' # https://github.com/drupal/drupal/blob/8.9.12/composer.lock#L4357-L4358 - [9.0]='1.10' # https://github.com/drupal/drupal/blob/9.0.10/composer.lock#L4448-L4449 - [9.1]='2.0' # https://github.com/drupal/drupal/blob/9.1.2/composer.lock#L4730-L4731 -) - -for version in "${versions[@]}"; do - rcGrepV='-v' - rcVersion="${version%-rc}" - 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.9, 9.0, 9.1 - drupalRelease='current' - ;; - esac - - fullVersion="$( - 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 } - release && tag == "version" { version = $1 } - release && tag == "mdhash" { mdhash = $1 } - release { tag = "" } - release && $1 == "/release" { release = 0; print version, mdhash } - ' \ - | grep -E "^${rcVersion}[. -]" \ - | grep $rcGrepV -E -- '-rc|-beta|-alpha|-dev' \ - | head -1 - )" - if [ -z "$fullVersion" ]; then - echo >&2 "error: cannot find release for $version" - exit 1 - fi - md5="${fullVersion##* }" - fullVersion="${fullVersion% $md5}" - - echo "$version: $fullVersion" - - for variant in {apache,fpm}-buster fpm-alpine3.12; do - [ -e "$version/$variant" ] || continue - dist='debian' - if [[ "$variant" = *alpine* ]]; then - dist='alpine' - fi - - phpImage="${phpVersions[$version]:-$defaultPhpVersion}-$variant" - sedArgs=( - -e 's/%%PHP_VERSION%%/'"${phpImage}"'/' - -e 's/%%VERSION%%/'"$fullVersion"'/' - -e 's/%%MD5%%/'"$md5"'/' - ) - - 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" - else - composerVersion="${composerVersions[$version]}" - sedArgs+=( -e 's/%%COMPOSER_VERSION%%/'"$composerVersion"'/' ) - fi - - sed -r "${sedArgs[@]}" "$template" > "$version/$variant/Dockerfile" - done -done +./versions.sh "$@" +./apply-templates.sh "$@" diff --git a/versions.json b/versions.json new file mode 100644 index 000000000..fed31ad57 --- /dev/null +++ b/versions.json @@ -0,0 +1,58 @@ +{ + "7": { + "md5": "67c8e2974421e8d549ad705169977498", + "phpVersions": [ + "7.4" + ], + "variants": [ + "apache-buster", + "fpm-buster", + "fpm-alpine3.12" + ], + "version": "7.78" + }, + "8.9": { + "composer": { + "version": "1.10" + }, + "md5": "75f7a83b14a1e4ec13ca9827f71ccd1c", + "phpVersions": [ + "7.4" + ], + "variants": [ + "apache-buster", + "fpm-buster", + "fpm-alpine3.12" + ], + "version": "8.9.13" + }, + "9.0": { + "composer": { + "version": "1.10" + }, + "phpVersions": [ + "7.4" + ], + "variants": [ + "apache-buster", + "fpm-buster", + "fpm-alpine3.12" + ], + "version": "9.0.11" + }, + "9.1": { + "composer": { + "version": "2.0" + }, + "phpVersions": [ + "8.0", + "7.4" + ], + "variants": [ + "apache-buster", + "fpm-buster", + "fpm-alpine3.12" + ], + "version": "9.1.3" + } +} diff --git a/versions.sh b/versions.sh new file mode 100755 index 000000000..5b5ae9613 --- /dev/null +++ b/versions.sh @@ -0,0 +1,102 @@ +#!/bin/bash +set -euo pipefail + +cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" + +versions=( "$@" ) +if [ ${#versions[@]} -eq 0 ]; then + versions=( */ ) + json='{}' +else + json="$(< versions.json)" +fi +versions=( "${versions[@]%/}" ) + +for version in "${versions[@]}"; do + export version + + doc='{}' + + rcGrepV='-v' + rcVersion="${version%-rc}" + 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.9, 9.0, 9.1 + drupalRelease='current' + ;; + esac + + fullVersion="$( + 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 } + release && tag == "version" { version = $1 } + release && tag == "mdhash" { mdhash = $1 } + release { tag = "" } + release && $1 == "/release" { release = 0; print version, mdhash } + ' \ + | grep -E "^${rcVersion}[. -]" \ + | grep $rcGrepV -E -- '-rc|-beta|-alpha|-dev' \ + | head -1 + )" + if [ -z "$fullVersion" ]; then + echo >&2 "error: cannot find release for $version" + exit 1 + fi + md5="${fullVersion##* }" + fullVersion="${fullVersion% $md5}" + if [ -n "$md5" ]; then + export md5 + doc="$(jq <<<"$doc" -c '.md5 = env.md5')" + fi + + composerVersion="$( + wget -qO- "https://github.com/drupal/drupal/raw/$fullVersion/composer.lock" \ + | jq -r ' + (.packages, ."packages-dev")[] + | select(.name == "composer/composer") + | .version + | split(".")[0:2] | join(".") + ' \ + || : + )" + if [ "$version" != '7' ] && [ -z "$composerVersion" ]; then + echo >&2 "error: cannot find composer version for '$version' ('$fullVersion')" + exit 1 + fi + if [ -n "$composerVersion" ]; then + export composerVersion + doc="$(jq <<<"$doc" -c '.composer = { version: env.composerVersion }')" + fi + + echo "$version: $fullVersion${composerVersion:+ (composer $composerVersion)}" + + export fullVersion + json="$( + jq <<<"$json" -c --argjson doc "$doc" ' + .[env.version] = { + version: env.fullVersion, + variants: [ "apache-buster", "fpm-buster", "fpm-alpine3.12" ], + phpVersions: ( + if [ "7", "8.9", "9.0"] | index(env.version) then + [ "7.4" ] + else + [ "8.0", "7.4" ] + end + ), + } + $doc + ' + )" +done + +jq <<<"$json" -S . > versions.json