Skip to content

Commit 62375f1

Browse files
committed
Templatize Dockerfiles for easier updating, fix libpng16 getting purged in stretch
1 parent 7216f79 commit 62375f1

File tree

12 files changed

+426
-111
lines changed

12 files changed

+426
-111
lines changed

7/apache/Dockerfile

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,55 @@
11
# from https://www.drupal.org/requirements/php#drupalversions
22
FROM php:7.0-apache
33

4-
RUN a2enmod rewrite
5-
64
# install the PHP extensions we need
7-
RUN set -ex \
8-
&& buildDeps=' \
9-
libjpeg62-turbo-dev \
10-
libpng12-dev \
5+
RUN set -ex; \
6+
\
7+
if command -v a2enmod; then \
8+
a2enmod rewrite; \
9+
fi; \
10+
\
11+
savedAptMark="$(apt-mark showmanual)"; \
12+
\
13+
apt-get update; \
14+
apt-get install -y --no-install-recommends \
15+
libjpeg-dev \
16+
libpng-dev \
1117
libpq-dev \
12-
' \
13-
&& apt-get update && apt-get install -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \
14-
&& docker-php-ext-configure gd \
15-
--with-jpeg-dir=/usr \
16-
--with-png-dir=/usr \
17-
&& docker-php-ext-install -j "$(nproc)" gd mbstring pdo pdo_mysql pdo_pgsql zip \
18-
# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/gd.so' - libjpeg.so.62: cannot open shared object file: No such file or directory in Unknown on line 0
19-
# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/pdo_pgsql.so' - libpq.so.5: cannot open shared object file: No such file or directory in Unknown on line 0
20-
&& apt-mark manual \
21-
libjpeg62-turbo \
22-
libpq5 \
23-
&& apt-get purge -y --auto-remove $buildDeps
18+
; \
19+
\
20+
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
21+
docker-php-ext-install -j "$(nproc)" \
22+
gd \
23+
opcache \
24+
pdo_mysql \
25+
pdo_pgsql \
26+
zip \
27+
; \
28+
\
29+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
30+
apt-mark auto '.*' > /dev/null; \
31+
apt-mark manual $savedAptMark; \
32+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
33+
| awk '/=>/ { print $3 }' \
34+
| sort -u \
35+
| xargs -r dpkg-query -S \
36+
| cut -d: -f1 \
37+
| sort -u \
38+
| xargs -rt apt-mark manual; \
39+
\
40+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
41+
rm -rf /var/lib/apt/lists/*
42+
43+
# set recommended PHP.ini settings
44+
# see https://secure.php.net/manual/en/opcache.installation.php
45+
RUN { \
46+
echo 'opcache.memory_consumption=128'; \
47+
echo 'opcache.interned_strings_buffer=8'; \
48+
echo 'opcache.max_accelerated_files=4000'; \
49+
echo 'opcache.revalidate_freq=60'; \
50+
echo 'opcache.fast_shutdown=1'; \
51+
echo 'opcache.enable_cli=1'; \
52+
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
2453

2554
WORKDIR /var/www/html
2655

@@ -32,4 +61,6 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta
3261
&& echo "${DRUPAL_MD5} *drupal.tar.gz" | md5sum -c - \
3362
&& tar -xz --strip-components=1 -f drupal.tar.gz \
3463
&& rm drupal.tar.gz \
35-
&& chown -R www-data:www-data sites
64+
&& chown -R www-data:www-data sites modules themes
65+
66+
# vim:set ft=dockerfile:

7/fpm-alpine/Dockerfile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ RUN set -ex \
1414
--with-freetype-dir=/usr/include/ \
1515
--with-jpeg-dir=/usr/include/ \
1616
--with-png-dir=/usr/include/ \
17-
&& docker-php-ext-install -j "$(nproc)" gd mbstring pdo pdo_mysql pdo_pgsql zip \
17+
&& docker-php-ext-install -j "$(nproc)" \
18+
gd \
19+
opcache \
20+
pdo_mysql \
21+
pdo_pgsql \
22+
zip \
1823
&& runDeps="$( \
1924
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
2025
| tr ',' '\n' \
@@ -24,6 +29,17 @@ RUN set -ex \
2429
&& apk add --virtual .drupal-phpexts-rundeps $runDeps \
2530
&& apk del .build-deps
2631

32+
# set recommended PHP.ini settings
33+
# see https://secure.php.net/manual/en/opcache.installation.php
34+
RUN { \
35+
echo 'opcache.memory_consumption=128'; \
36+
echo 'opcache.interned_strings_buffer=8'; \
37+
echo 'opcache.max_accelerated_files=4000'; \
38+
echo 'opcache.revalidate_freq=60'; \
39+
echo 'opcache.fast_shutdown=1'; \
40+
echo 'opcache.enable_cli=1'; \
41+
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
42+
2743
WORKDIR /var/www/html
2844

2945
# https://www.drupal.org/node/3060/release
@@ -34,4 +50,6 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta
3450
&& echo "${DRUPAL_MD5} *drupal.tar.gz" | md5sum -c - \
3551
&& tar -xz --strip-components=1 -f drupal.tar.gz \
3652
&& rm drupal.tar.gz \
37-
&& chown -R www-data:www-data sites
53+
&& chown -R www-data:www-data sites modules themes
54+
55+
# vim:set ft=dockerfile:

7/fpm/Dockerfile

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,54 @@
22
FROM php:7.0-fpm
33

44
# install the PHP extensions we need
5-
RUN set -ex \
6-
&& buildDeps=' \
7-
libjpeg62-turbo-dev \
8-
libpng12-dev \
5+
RUN set -ex; \
6+
\
7+
if command -v a2enmod; then \
8+
a2enmod rewrite; \
9+
fi; \
10+
\
11+
savedAptMark="$(apt-mark showmanual)"; \
12+
\
13+
apt-get update; \
14+
apt-get install -y --no-install-recommends \
15+
libjpeg-dev \
16+
libpng-dev \
917
libpq-dev \
10-
' \
11-
&& apt-get update && apt-get install -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \
12-
&& docker-php-ext-configure gd \
13-
--with-jpeg-dir=/usr \
14-
--with-png-dir=/usr \
15-
&& docker-php-ext-install -j "$(nproc)" gd mbstring pdo pdo_mysql pdo_pgsql zip \
16-
# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/gd.so' - libjpeg.so.62: cannot open shared object file: No such file or directory in Unknown on line 0
17-
# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/pdo_pgsql.so' - libpq.so.5: cannot open shared object file: No such file or directory in Unknown on line 0
18-
&& apt-mark manual \
19-
libjpeg62-turbo \
20-
libpq5 \
21-
&& apt-get purge -y --auto-remove $buildDeps
18+
; \
19+
\
20+
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
21+
docker-php-ext-install -j "$(nproc)" \
22+
gd \
23+
opcache \
24+
pdo_mysql \
25+
pdo_pgsql \
26+
zip \
27+
; \
28+
\
29+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
30+
apt-mark auto '.*' > /dev/null; \
31+
apt-mark manual $savedAptMark; \
32+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
33+
| awk '/=>/ { print $3 }' \
34+
| sort -u \
35+
| xargs -r dpkg-query -S \
36+
| cut -d: -f1 \
37+
| sort -u \
38+
| xargs -rt apt-mark manual; \
39+
\
40+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
41+
rm -rf /var/lib/apt/lists/*
42+
43+
# set recommended PHP.ini settings
44+
# see https://secure.php.net/manual/en/opcache.installation.php
45+
RUN { \
46+
echo 'opcache.memory_consumption=128'; \
47+
echo 'opcache.interned_strings_buffer=8'; \
48+
echo 'opcache.max_accelerated_files=4000'; \
49+
echo 'opcache.revalidate_freq=60'; \
50+
echo 'opcache.fast_shutdown=1'; \
51+
echo 'opcache.enable_cli=1'; \
52+
} > /usr/local/etc/php/conf.d/opcache-recommended.ini
2253

2354
WORKDIR /var/www/html
2455

@@ -30,4 +61,6 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta
3061
&& echo "${DRUPAL_MD5} *drupal.tar.gz" | md5sum -c - \
3162
&& tar -xz --strip-components=1 -f drupal.tar.gz \
3263
&& rm drupal.tar.gz \
33-
&& chown -R www-data:www-data sites
64+
&& chown -R www-data:www-data sites modules themes
65+
66+
# vim:set ft=dockerfile:

8.4/apache/Dockerfile

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,44 @@
11
# from https://www.drupal.org/requirements/php#drupalversions
22
FROM php:7.1-apache
33

4-
RUN a2enmod rewrite
5-
64
# install the PHP extensions we need
7-
RUN set -ex \
8-
&& buildDeps=' \
9-
libjpeg62-turbo-dev \
5+
RUN set -ex; \
6+
\
7+
if command -v a2enmod; then \
8+
a2enmod rewrite; \
9+
fi; \
10+
\
11+
savedAptMark="$(apt-mark showmanual)"; \
12+
\
13+
apt-get update; \
14+
apt-get install -y --no-install-recommends \
15+
libjpeg-dev \
1016
libpng-dev \
1117
libpq-dev \
12-
' \
13-
&& apt-get update && apt-get install -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \
14-
&& docker-php-ext-configure gd \
15-
--with-jpeg-dir=/usr \
16-
--with-png-dir=/usr \
17-
&& docker-php-ext-install -j "$(nproc)" gd mbstring opcache pdo pdo_mysql pdo_pgsql zip \
18-
# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/gd.so' - libjpeg.so.62: cannot open shared object file: No such file or directory in Unknown on line 0
19-
# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/pdo_pgsql.so' - libpq.so.5: cannot open shared object file: No such file or directory in Unknown on line 0
20-
&& apt-mark manual \
21-
libjpeg62-turbo \
22-
libpq5 \
23-
&& apt-get purge -y --auto-remove $buildDeps
18+
; \
19+
\
20+
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
21+
docker-php-ext-install -j "$(nproc)" \
22+
gd \
23+
opcache \
24+
pdo_mysql \
25+
pdo_pgsql \
26+
zip \
27+
; \
28+
\
29+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
30+
apt-mark auto '.*' > /dev/null; \
31+
apt-mark manual $savedAptMark; \
32+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
33+
| awk '/=>/ { print $3 }' \
34+
| sort -u \
35+
| xargs -r dpkg-query -S \
36+
| cut -d: -f1 \
37+
| sort -u \
38+
| xargs -rt apt-mark manual; \
39+
\
40+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
41+
rm -rf /var/lib/apt/lists/*
2442

2543
# set recommended PHP.ini settings
2644
# see https://secure.php.net/manual/en/opcache.installation.php
@@ -44,3 +62,5 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta
4462
&& tar -xz --strip-components=1 -f drupal.tar.gz \
4563
&& rm drupal.tar.gz \
4664
&& chown -R www-data:www-data sites modules themes
65+
66+
# vim:set ft=dockerfile:

8.4/fpm-alpine/Dockerfile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ RUN set -ex \
1414
--with-freetype-dir=/usr/include/ \
1515
--with-jpeg-dir=/usr/include/ \
1616
--with-png-dir=/usr/include/ \
17-
&& docker-php-ext-install -j "$(nproc)" gd mbstring opcache pdo pdo_mysql pdo_pgsql zip \
17+
&& docker-php-ext-install -j "$(nproc)" \
18+
gd \
19+
opcache \
20+
pdo_mysql \
21+
pdo_pgsql \
22+
zip \
1823
&& runDeps="$( \
1924
scanelf --needed --nobanner --format '%n#p' --recursive /usr/local \
2025
| tr ',' '\n' \
@@ -46,3 +51,5 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta
4651
&& tar -xz --strip-components=1 -f drupal.tar.gz \
4752
&& rm drupal.tar.gz \
4853
&& chown -R www-data:www-data sites modules themes
54+
55+
# vim:set ft=dockerfile:

8.4/fpm/Dockerfile

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,43 @@
22
FROM php:7.1-fpm
33

44
# install the PHP extensions we need
5-
RUN set -ex \
6-
&& buildDeps=' \
7-
libjpeg62-turbo-dev \
5+
RUN set -ex; \
6+
\
7+
if command -v a2enmod; then \
8+
a2enmod rewrite; \
9+
fi; \
10+
\
11+
savedAptMark="$(apt-mark showmanual)"; \
12+
\
13+
apt-get update; \
14+
apt-get install -y --no-install-recommends \
15+
libjpeg-dev \
816
libpng-dev \
917
libpq-dev \
10-
' \
11-
&& apt-get update && apt-get install -y --no-install-recommends $buildDeps && rm -rf /var/lib/apt/lists/* \
12-
&& docker-php-ext-configure gd \
13-
--with-jpeg-dir=/usr \
14-
--with-png-dir=/usr \
15-
&& docker-php-ext-install -j "$(nproc)" gd mbstring opcache pdo pdo_mysql pdo_pgsql zip \
16-
# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/gd.so' - libjpeg.so.62: cannot open shared object file: No such file or directory in Unknown on line 0
17-
# PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20151012/pdo_pgsql.so' - libpq.so.5: cannot open shared object file: No such file or directory in Unknown on line 0
18-
&& apt-mark manual \
19-
libjpeg62-turbo \
20-
libpq5 \
21-
&& apt-get purge -y --auto-remove $buildDeps
18+
; \
19+
\
20+
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
21+
docker-php-ext-install -j "$(nproc)" \
22+
gd \
23+
opcache \
24+
pdo_mysql \
25+
pdo_pgsql \
26+
zip \
27+
; \
28+
\
29+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
30+
apt-mark auto '.*' > /dev/null; \
31+
apt-mark manual $savedAptMark; \
32+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
33+
| awk '/=>/ { print $3 }' \
34+
| sort -u \
35+
| xargs -r dpkg-query -S \
36+
| cut -d: -f1 \
37+
| sort -u \
38+
| xargs -rt apt-mark manual; \
39+
\
40+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
41+
rm -rf /var/lib/apt/lists/*
2242

2343
# set recommended PHP.ini settings
2444
# see https://secure.php.net/manual/en/opcache.installation.php
@@ -42,3 +62,5 @@ RUN curl -fSL "https://ftp.drupal.org/files/projects/drupal-${DRUPAL_VERSION}.ta
4262
&& tar -xz --strip-components=1 -f drupal.tar.gz \
4363
&& rm drupal.tar.gz \
4464
&& chown -R www-data:www-data sites modules themes
65+
66+
# vim:set ft=dockerfile:

0 commit comments

Comments
 (0)