-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathphp.Dockerfile
executable file
·99 lines (89 loc) · 3.18 KB
/
php.Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# Inspired by the official Drupal alpine image
# See: https://github.com/docker-library/drupal
ARG PHP_VERSION
# from https://www.drupal.org/docs/8/system-requirements/drupal-8-php-requirements
FROM php:${PHP_VERSION}-fpm-alpine
# install the PHP extensions we need
# Memcahed installation: https://stackoverflow.com/a/41575677
# Soap installation: https://github.com/docker-library/php/issues/315#issuecomment-264645332
# Imagick installation: https://gist.github.com/johndatserakis/825a16a7f3cef4e8b4dbfbb1e80b9f9c
# postgresql-dev is needed for https://bugs.alpinelinux.org/issues/3642
RUN set -eux \
&& apk update \
&& apk add --no-cache --update --virtual .phpize-deps $PHPIZE_DEPS \
&& apk add --no-cache --update --virtual .build-deps \
# This is needed for installing PECL extensions (appearently).
$PHPIZE_DEPS \
coreutils \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libzip-dev \
postgresql-dev \
zlib-dev \
libmemcached-dev \
cyrus-sasl-dev \
libxml2-dev \
imagemagick-dev \
libtool \
&& docker-php-ext-configure gd \
--with-freetype-dir=/usr/include/ \
--with-jpeg-dir=/usr/include/ \
--with-png-dir=/usr/include/ \
&& docker-php-ext-install -j "$(nproc)" \
gd \
opcache \
pdo_mysql \
pdo_pgsql \
zip \
soap \
&& \
if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
pecl install memcache-3.0.8; \
else \
pecl install memcache-4.0.5.2; \
fi \
&& pecl install imagick-3.4.4 \
&& \
if [ $(php -r "echo PHP_MAJOR_VERSION;") = "5" ]; then \
pecl install xdebug-2.5.5; \
else \
pecl install xdebug-2.7.2; \
fi \
# Do not enable xdebug by default for performance reasons.
&& docker-php-ext-enable memcache imagick \
&& runDeps="$( \
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
| tr ',' '\n' \
| sort -u \
| awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \
)" \
&& apk add --virtual .drupal-phpexts-rundeps $runDeps \
&& apk del .build-deps .phpize-deps \
&& rm -rf /usr/share/php7 \
&& rm -rf /tmp/*
# 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=0'; \
echo 'opcache.fast_shutdown=1'; \
echo 'opcache.enable_cli=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
# Default production configuration is optimized and recommended to use
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY --from=composer:1.9.1 /usr/bin/composer /usr/bin/composer
# Install Drush using Composer.
RUN composer global require drush/drush:"8.1.16" --prefer-dist \
&& rm -f /usr/local/bin/drush \
&& ln -s ~/.composer/vendor/bin/drush /usr/local/bin/drush \
&& drush core-status -y
# Drush is basically useless without a mysql client.
RUN set -eux \
&& apk add --no-cache --update mariadb-client \
&& rm -f /var/cache/apk/*
# Add own php configuration
COPY files/php/conf $PHP_INI_DIR/conf.d/
WORKDIR /var/www