Skip to content

Instantly share code, notes, and snippets.

@desaijay315
Created December 3, 2020 10:43
Show Gist options
  • Save desaijay315/3cd5a143fcdc449493245f76324581bc to your computer and use it in GitHub Desktop.
Save desaijay315/3cd5a143fcdc449493245f76324581bc to your computer and use it in GitHub Desktop.
# 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
# install the PHP extensions we need
RUN set -ex; \
\
if command -v a2enmod; then \
a2enmod rewrite; \
a2enmod headers; \
fi; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
libjpeg-dev \
libpng-dev \
libpq-dev \
; \
\
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/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'; \
echo 'opcache.enable_cli=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
# upload config
#RUN { \
# echo 'upload_max_filesize=50M'; \
# echo 'post_max_size=50M'; \
# echo 'max_input_vars=5000';
# echo 'expose_php=Off'; \
# } > /usr/local/etc/php/conf.d/uploads.ini
WORKDIR /var/www/drupal
# https://github.com/drupal/drupal/blob/9.0.1/composer.lock#L4052-L4053
# COPY --from=composer:1.10 /usr/bin/composer /usr/local/bin/
COPY example-cms ./
# https://www.drupal.org/node/3060/release
ENV DRUPAL_VERSION 8.9.1
RUN { \
echo '<VirtualHost *:80>\n'; \
echo 'DocumentRoot /var/www/drupal/web\n'; \
#echo 'ErrorLog $${APACHE_LOG_DIR}/error.log\n'; \
#echo 'CustomLog $${APACHE_LOG_DIR}/access.log combined\n'; \
echo '</VirtualHost>\n'; \
} > /etc/apache2/sites-enabled/000-default.conf
RUN { \
echo 'ServerTokens Prod\n'; \
echo 'ServerSignature Off\n'; \
echo 'TraceEnable Off\n'; \
echo 'Header set X-Frame-Options: "SAMEORIGIN"\n'; \
echo 'Header set X-DNS-Prefetch-Control: "off"\n'; \
echo 'Header set Strict-Transport-Security: "max-age=15552000; includeSubDomains"\n'; \
echo 'Header set X-XSS-Protection: "1; mode=block"\n'; \
} > /etc/apache2/conf-enabled/security.conf
RUN { \
echo '<IfModule alias_module>\n</IfModule>\n'; \
} > /etc/apache2/mods-enabled/alias.conf
#VOLUME /var/www/drupal
RUN apt-get update && apt-get install -y nano && apt-get install -y vim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment