-
Notifications
You must be signed in to change notification settings - Fork 204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 9.0, "buster" aliases, and use "drupal/recommended-project" layout #176
Changes from 3 commits
71ffa1c
0785264
999ac25
4a5ce8d
530833e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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,23 @@ 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 | ||
|
||
# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053 | ||
COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/ | ||
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)"; \ | ||
cd /var/www/; \ | ||
# composer won't install to a non-empty dir: 'Project directory "/var/www/" is not empty.' | ||
rmdir /var/www/html; \ | ||
composer create-project --no-install "drupal/recommended-project:$DRUPAL_VERSION" ./; \ | ||
sed -i 's!web/!html/!g' composer.json; \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we maybe not do this for 9.0+? (I understand why we would do it for 8.x to keep backwards compatibility, but if it's the "recommended" layout, perhaps we should follow it for the new versions and update our Apache configuration instead?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking to always do it so that we don't have the weird transition for users where they get confused that their mount for (honestly the "recommended" layout should have some way to choose the target subdirectory) I guess we could do both by installing to web and making html a symlink? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Letting it install where they "recommend" and having our own symlink seems sane IMO -- gives us a good balance of following their official layout and not breaking users. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can provide it like:
per the documentation: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. or am I misunderstanding the problem? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as far as I know, the "root" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it might be weird if someone mounts the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What it sounds like is that we're maybe looking at the problem in the wrong way -- what if we instead install to something like
Maybe there's even an official upstream-recommended location for a "system" install (rather than inventing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That seems reasonable to me. That means I do not know of a system install location convention, so whatever you think is best. Is there a convention in Docker? maybe The documentation should probably be updated to use/mount It would be nice if I could extend the image, and do something like:
and have it install the Paragraphs module as is described in the documentation: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great example usage! After some tweaks that I'll push up shorty, this will work just fine. $ docker build -
FROM drupal:8.9-new
RUN composer require 'drupal/paragraphs:^1.12'
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM drupal:8.9-new
---> 82e0b578fbc4
Step 2/2 : RUN composer require 'drupal/paragraphs:^1.12'
---> Running in d7ad66c57f7b
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension.
This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost.
Installing 'unzip' may remediate them.
- Installing drupal/entity_reference_revisions (1.8.0): Downloading (100%)
- Installing drupal/paragraphs (1.12.0): Downloading (100%)
drupal/paragraphs suggests installing drupal/entity_browser (Recommended for an improved user experience when using the Paragraphs library module)
Writing lock file
Generating autoload files
23 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
Removing intermediate container d7ad66c57f7b
---> fc0923aa982b
Successfully built fc0923aa982b |
||
composer install; \ | ||
yosifkit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cd html; \ | ||
chown -R www-data:www-data sites modules themes; \ | ||
# delete composer cache | ||
rm -rf "$COMPOSER_HOME" | ||
|
||
WORKDIR /var/www/html | ||
yosifkit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# vim:set ft=dockerfile: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# 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://www.drupal.org/node/3060/release | ||
ENV DRUPAL_VERSION 9.0.2 | ||
|
||
# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053 | ||
COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/ | ||
RUN set -eux; \ | ||
export COMPOSER_HOME="$(mktemp -d)"; \ | ||
cd /var/www/; \ | ||
# composer won't install to a non-empty dir: 'Project directory "/var/www/" is not empty.' | ||
rmdir /var/www/html; \ | ||
composer create-project --no-install "drupal/recommended-project:$DRUPAL_VERSION" ./; \ | ||
sed -i 's!web/!html/!g' composer.json; \ | ||
composer install; \ | ||
cd html; \ | ||
chown -R www-data:www-data sites modules themes; \ | ||
# delete composer cache | ||
rm -rf "$COMPOSER_HOME" | ||
|
||
WORKDIR /var/www/html | ||
# vim:set ft=dockerfile: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully the time period between releases to https://github.com/drupal/drupal/releases (and I guess more relevantly, new version numbers presented in the update API we're scraping) and new tags on https://github.com/drupal/recommended-project/releases is short. 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I would hope this will be updated in a timely fashion on each release.