Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 31 additions & 27 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
FROM php:7.2-apache-stretch
MAINTAINER Firespring "info.dev@firespring.com"

ENV DEBIAN_FRONTEND noninteractive
ENV SERVER_NAME=localhost
ENV APACHE_RUN_USER=www-data
ENV APACHE_RUN_GROUP=www-data
ENV APACHE_PID_FILE=/var/run/apache2/apache2.pid
ENV APACHE_RUN_DIR=/var/run/apache2
ENV APACHE_LOCK_DIR=/var/lock/apache2
ENV APACHE_LOG_DIR=/var/log/apache2
ENV APACHE_LOG_LEVEL=warn
ENV APACHE_CUSTOM_LOG_FILE=/proc/self/fd/1
ENV APACHE_ERROR_LOG_FILE=/proc/self/fd/2
ENV DEBIAN_FRONTEND="noninteractive" \
SERVER_NAME="localhost" \
APACHE_RUN_USER="www-data" \
APACHE_RUN_GROUP="www-data" \
APACHE_PID_FILE="/var/run/apache2/apache2.pid" \
APACHE_RUN_DIR="/var/run/apache2" \
APACHE_LOCK_DIR="/var/lock/apache2" \
APACHE_LOG_DIR="/var/log/apache2" \
APACHE_LOG_LEVEL="warn" \
APACHE_CUSTOM_LOG_FILE="/proc/self/fd/1" \
APACHE_ERROR_LOG_FILE="/proc/self/fd/2" \
PHP_OPCACHE_VALIDATE_TIMESTAMPS="0" \
PHP_OPCACHE_MAX_ACCELERATED_FILES="10000" \
PHP_OPCACHE_MEMORY_CONSUMPTION="192" \
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"

RUN mkdir -p /var/run/apache2 /var/lock/apache2

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install apt-utils apt-transport-https software-properties-common gnupg

RUN apt-get update && LC_ALL=C.UTF-8 add-apt-repository 'deb https://packages.sury.org/php/ stretch main' \
&& apt-key adv --fetch-keys https://packages.sury.org/php/apt.gpg

# Use the default production configuration
# except Prioritize Sury php-gd package
RUN set -eux; \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install apt-utils apt-transport-https software-properties-common gnupg \
&& LC_ALL=C.UTF-8 add-apt-repository 'deb https://packages.sury.org/php/ stretch main' \
&& apt-key adv --fetch-keys https://packages.sury.org/php/apt.gpg \
# Use the default production configuration
# except Prioritize Sury php-gd package
&& set -eux; \
{ \
echo 'Package: php*-gd'; \
echo 'Pin: release *'; \
echo 'Pin-Priority: 1'; \
} >> /etc/apt/preferences.d/no-debian-php

RUN apt-get update && apt-get install -y --force-yes \
} >> /etc/apt/preferences.d/no-debian-php \
&& apt-get update && apt-get install -y --force-yes \
# Apache\PHP
php-mysql php-dev php-gd php-redis libhiredis-dev libhiredis0.13 libphp-predis \
libapache2-mod-gnutls php-zip php-cli php-xcache \
libapache2-mod-gnutls php-zip php-cli \
# Build Deps
build-essential curl make \
# Other Deps
pdftk zip git libpng-dev libjpeg-dev libjpeg62-turbo-dev libfreetype6-dev libwebp-dev libxpm-dev
pdftk zip git libpng-dev libjpeg-dev libjpeg62-turbo-dev libfreetype6-dev libwebp-dev libxpm-dev \
# clean up packages here otherwise the files will be in every layer
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# install and configure php modules
RUN pecl config-set php_ini "$PHP_INI_DIR" \
&& pear install PHP_CodeSniffer \
&& pecl install xdebug-2.6.1 \
Expand All @@ -47,6 +52,7 @@ RUN pecl config-set php_ini "$PHP_INI_DIR" \
&& docker-php-ext-enable redis \
&& docker-php-ext-install mysqli \
&& docker-php-ext-install zip \
&& docker-php-ext-install opcache \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd

Expand All @@ -70,15 +76,13 @@ RUN git clone https://github.com/nrk/phpiredis.git \

RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer

RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Apache Config
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_RUN_DIR /var/run/apache2
ENV APPLICATION_ENV local

COPY apache2/apache2.conf /etc/apache2/
COPY php/conf.d/opcache.ini /usr/local/etc/php/conf.d/opcache.ini

COPY apache2-foreground /usr/local/bin/

Expand Down
11 changes: 11 additions & 0 deletions php/conf.d/opcache.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[opcache]

opcache.enable=1
opcache.revalidate_freq=0
opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}
opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}
opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}
opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}
opcache.interned_strings_buffer=16

opcache.fast_shutdown=1