From 46605b04e975cb9757e9c0faa6c01a1d6c5db375 Mon Sep 17 00:00:00 2001 From: Nigel Banks Date: Tue, 24 Nov 2020 19:47:36 +0000 Subject: [PATCH] Composer 2 (#85) * Allow drush to be called as non-root user. * Upgrade to composer version 2. --- crayfish/Dockerfile | 2 +- crayfits/Dockerfile | 2 +- demo/Dockerfile | 9 ++++----- drupal/rootfs/usr/local/bin/drush | 9 ++++++++- nginx/Dockerfile | 20 ++++++++++++++++++-- 5 files changed, 32 insertions(+), 10 deletions(-) diff --git a/crayfish/Dockerfile b/crayfish/Dockerfile index 1e69bfe7..b568b30c 100644 --- a/crayfish/Dockerfile +++ b/crayfish/Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:experimental FROM local/nginx:latest -ARG COMMIT=1.1.1 +ARG COMMIT=85a8206a9ed1db302fdeb123f9d5391ef8aae001 RUN --mount=id=downloads,type=cache,target=/opt/downloads \ DOWNLOAD_CACHE_DIRECTORY="/opt/downloads" && \ diff --git a/crayfits/Dockerfile b/crayfits/Dockerfile index 87ed82be..aea122b3 100644 --- a/crayfits/Dockerfile +++ b/crayfits/Dockerfile @@ -1,7 +1,7 @@ # syntax=docker/dockerfile:experimental FROM local/nginx:latest -ARG COMMIT=4e0faeb31f84e74e7cecc083b2f096d55e425fbb +ARG COMMIT=6e95f2f325c910b254a2b7bd1cedf25b17874d30 RUN --mount=type=cache,target=/root/.composer/cache \ --mount=id=downloads,type=cache,target=/opt/downloads \ diff --git a/demo/Dockerfile b/demo/Dockerfile index 0fc62ab9..70f36f6d 100644 --- a/demo/Dockerfile +++ b/demo/Dockerfile @@ -5,7 +5,7 @@ FROM local/nginx:latest as composer RUN --mount=type=cache,target=/root/.composer/cache \ --mount=id=downloads,type=cache,target=/opt/downloads \ DOWNLOAD_CACHE_DIRECTORY="/opt/downloads" && \ - composer create-project islandora/drupal-project:8.8.1 \ + composer create-project drupal/recommended-project:^8.9 \ --prefer-dist \ --no-interaction \ --stability stable \ @@ -16,7 +16,6 @@ RUN --mount=type=cache,target=/root/.composer/cache \ cd /var/www/drupal && \ composer require --update-no-dev -- \ drupal/admin_toolbar:^2.0 \ - drupal/console:~1.0 \ drupal/content_browser:^1.0@alpha \ drupal/devel:^2.0 \ drupal/facets:^1.3 \ @@ -27,11 +26,11 @@ RUN --mount=type=cache,target=/root/.composer/cache \ drupal/restui:^1.16 \ drupal/search_api_solr:^3.8 \ drupal/transliterate_filenames:^1.3 \ - drush/drush:^9.7.1 \ - islandora-rdm/islandora_fits:dev-master \ + drush/drush:^10.3 \ + islandora-rdm/islandora_fits:dev-8.x-1.x \ islandora/carapace:dev-8.x-3.x \ islandora/islandora_defaults:dev-8.x-1.x \ - zaporylie/composer-drupal-optimizations:^1.0 \ + zaporylie/composer-drupal-optimizations:^1.1 \ && \ mkdir -p /var/www/drupal/web/libraries && \ MASONRY_VERSION="3.3.2" && \ diff --git a/drupal/rootfs/usr/local/bin/drush b/drupal/rootfs/usr/local/bin/drush index 8598f6ae..28ee536f 100755 --- a/drupal/rootfs/usr/local/bin/drush +++ b/drupal/rootfs/usr/local/bin/drush @@ -4,4 +4,11 @@ set -e # Ensures drush runs as the correct user, and does not run out of memory. # Takes precedence due to order of $PATH. Preferred to an alias as it will apply # regardless of which shell is used or how it is started (login, interactive, etc) -s6-setuidgid nginx php -d memory_limit=-1 /usr/bin/drush "${@}" +if test $(id -u) -eq 0; then + # If root run as nginx. + s6-setuidgid nginx php -d memory_limit=-1 /usr/bin/drush "${@}" +else + # If non-root user, then run as current user + # as we do not have permissions to switch user. + php -d memory_limit=-1 /usr/bin/drush "${@}" +fi diff --git a/nginx/Dockerfile b/nginx/Dockerfile index b395d84d..8759e599 100644 --- a/nginx/Dockerfile +++ b/nginx/Dockerfile @@ -4,19 +4,24 @@ FROM local/base:latest RUN --mount=type=cache,target=/var/cache/apk \ --mount=type=cache,target=/etc/cache/apk \ apk-install.sh \ - composer \ nginx \ + php7 \ php7-ctype \ php7-curl \ php7-dom \ php7-fileinfo \ php7-fpm \ php7-gd \ + php7-iconv \ + php7-json \ + php7-mbstring \ + php7-mysqli \ php7-opcache \ + php7-openssl \ php7-pdo \ php7-pdo_mysql \ php7-pdo_pgsql \ - php7-mysqli \ + php7-phar \ php7-session \ php7-simplexml \ php7-tokenizer \ @@ -26,4 +31,15 @@ RUN --mount=type=cache,target=/var/cache/apk \ && \ cleanup.sh +# https://getcomposer.org/download/ +RUN --mount=id=downloads,type=cache,target=/opt/downloads \ + DOWNLOAD_CACHE_DIRECTORY="/opt/downloads" && \ + COMPOSER_VERSION="2.0.4" && \ + COMPOSER_FILE="composer.phar" && \ + COMPOSER_URL="https://getcomposer.org/download/${COMPOSER_VERSION}/${COMPOSER_FILE}" && \ + COMPOSER_SHA256="c3b2bc477429c923c69f7f9b137e06b2a93c6a1e192d40ffad1741ee5d54760d" && \ + download.sh --url "${COMPOSER_URL}" --sha256 "${COMPOSER_SHA256}" "${DOWNLOAD_CACHE_DIRECTORY}" && \ + cp "${DOWNLOAD_CACHE_DIRECTORY}/${COMPOSER_FILE}" /usr/bin/composer && \ + chmod a+x /usr/bin/composer + COPY rootfs /