automation/deployer/roles/build/templates/drupal/Dockerfile.php.j2

84 lines
2.1 KiB
Django/Jinja

FROM php:7.4-apache-buster
# install the PHP extensions we need
# Code taken from https://github.com/docker-library/drupal
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 \
msmtp \
; \
\
docker-php-ext-configure gd \
--with-freetype-dir=/usr \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
; \
\
docker-php-ext-install -j "$(nproc)" \
gd \
opcache \
pdo_mysqli \
# 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
# Configure msmtp
RUN echo "\
account default\n\
host {{ site.subnet_gateway_ip }}\n\
port 25\n\
from php@{{ site.url }}\n" > /etc/msmtprc
# Send mails using msmtp
RUN echo "sendmail_path = /usr/bin/msmtp -t " > /usr/local/etc/php/conf.d/sendmail.ini
WORKDIR /var/www/html
# https://www.drupal.org/node/3060/release
ENV DRUPAL_VERSION 8.8.5
ENV DRUPAL_MD5 11e595f6aa42fca4ab4423bff0b09c28
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