Skip to content

Commit

Permalink
Composer 2 (#85)
Browse files Browse the repository at this point in the history
* Allow drush to be called as non-root user.

* Upgrade to composer version 2.
  • Loading branch information
nigelgbanks authored Nov 24, 2020
1 parent 06b1d3b commit 46605b0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion crayfish/Dockerfile
Original file line number Diff line number Diff line change
@@ -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" && \
Expand Down
2 changes: 1 addition & 1 deletion crayfits/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
9 changes: 4 additions & 5 deletions demo/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand All @@ -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" && \
Expand Down
9 changes: 8 additions & 1 deletion drupal/rootfs/usr/local/bin/drush
Original file line number Diff line number Diff line change
Expand Up @@ -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
20 changes: 18 additions & 2 deletions nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 /

0 comments on commit 46605b0

Please sign in to comment.