Skip to content

Commit 583768e

Browse files
authored
Merge pull request #267 from J0WI/buildDeps
Remove the *-dev deps and only keep the necessary lib* packages
2 parents 0bd788e + 6a085d9 commit 583768e

File tree

9 files changed

+162
-36
lines changed

9 files changed

+162
-36
lines changed

Dockerfile-debian.template

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@ FROM php:%%PHP_VERSION%%-%%VARIANT%%
22

33
# install the PHP extensions we need
44
RUN set -ex; \
5+
\
6+
savedAptMark="$(apt-mark showmanual)"; \
57
\
68
apt-get update; \
7-
apt-get install -y \
9+
apt-get install -y --no-install-recommends \
810
libjpeg-dev \
911
libpng-dev \
1012
; \
11-
rm -rf /var/lib/apt/lists/*; \
1213
\
1314
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
14-
docker-php-ext-install gd mysqli opcache
15-
# TODO consider removing the *-dev deps and only keeping the necessary lib* packages
15+
docker-php-ext-install gd mysqli opcache; \
16+
\
17+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
18+
apt-mark auto '.*' > /dev/null; \
19+
apt-mark manual $savedAptMark; \
20+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
21+
| awk '/=>/ { print $3 }' \
22+
| sort -u \
23+
| xargs -r dpkg-query -S \
24+
| cut -d: -f1 \
25+
| sort -u \
26+
| xargs -rt apt-mark manual; \
27+
\
28+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
29+
rm -rf /var/lib/apt/lists/*
1630

1731
# set recommended PHP.ini settings
1832
# see https://secure.php.net/manual/en/opcache.installation.php

php5.6/apache/Dockerfile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@ FROM php:5.6-apache
22

33
# install the PHP extensions we need
44
RUN set -ex; \
5+
\
6+
savedAptMark="$(apt-mark showmanual)"; \
57
\
68
apt-get update; \
7-
apt-get install -y \
9+
apt-get install -y --no-install-recommends \
810
libjpeg-dev \
911
libpng-dev \
1012
; \
11-
rm -rf /var/lib/apt/lists/*; \
1213
\
1314
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
14-
docker-php-ext-install gd mysqli opcache
15-
# TODO consider removing the *-dev deps and only keeping the necessary lib* packages
15+
docker-php-ext-install gd mysqli opcache; \
16+
\
17+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
18+
apt-mark auto '.*' > /dev/null; \
19+
apt-mark manual $savedAptMark; \
20+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
21+
| awk '/=>/ { print $3 }' \
22+
| sort -u \
23+
| xargs -r dpkg-query -S \
24+
| cut -d: -f1 \
25+
| sort -u \
26+
| xargs -rt apt-mark manual; \
27+
\
28+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
29+
rm -rf /var/lib/apt/lists/*
1630

1731
# set recommended PHP.ini settings
1832
# see https://secure.php.net/manual/en/opcache.installation.php

php5.6/fpm/Dockerfile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@ FROM php:5.6-fpm
22

33
# install the PHP extensions we need
44
RUN set -ex; \
5+
\
6+
savedAptMark="$(apt-mark showmanual)"; \
57
\
68
apt-get update; \
7-
apt-get install -y \
9+
apt-get install -y --no-install-recommends \
810
libjpeg-dev \
911
libpng-dev \
1012
; \
11-
rm -rf /var/lib/apt/lists/*; \
1213
\
1314
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
14-
docker-php-ext-install gd mysqli opcache
15-
# TODO consider removing the *-dev deps and only keeping the necessary lib* packages
15+
docker-php-ext-install gd mysqli opcache; \
16+
\
17+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
18+
apt-mark auto '.*' > /dev/null; \
19+
apt-mark manual $savedAptMark; \
20+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
21+
| awk '/=>/ { print $3 }' \
22+
| sort -u \
23+
| xargs -r dpkg-query -S \
24+
| cut -d: -f1 \
25+
| sort -u \
26+
| xargs -rt apt-mark manual; \
27+
\
28+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
29+
rm -rf /var/lib/apt/lists/*
1630

1731
# set recommended PHP.ini settings
1832
# see https://secure.php.net/manual/en/opcache.installation.php

php7.0/apache/Dockerfile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@ FROM php:7.0-apache
22

33
# install the PHP extensions we need
44
RUN set -ex; \
5+
\
6+
savedAptMark="$(apt-mark showmanual)"; \
57
\
68
apt-get update; \
7-
apt-get install -y \
9+
apt-get install -y --no-install-recommends \
810
libjpeg-dev \
911
libpng-dev \
1012
; \
11-
rm -rf /var/lib/apt/lists/*; \
1213
\
1314
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
14-
docker-php-ext-install gd mysqli opcache
15-
# TODO consider removing the *-dev deps and only keeping the necessary lib* packages
15+
docker-php-ext-install gd mysqli opcache; \
16+
\
17+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
18+
apt-mark auto '.*' > /dev/null; \
19+
apt-mark manual $savedAptMark; \
20+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
21+
| awk '/=>/ { print $3 }' \
22+
| sort -u \
23+
| xargs -r dpkg-query -S \
24+
| cut -d: -f1 \
25+
| sort -u \
26+
| xargs -rt apt-mark manual; \
27+
\
28+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
29+
rm -rf /var/lib/apt/lists/*
1630

1731
# set recommended PHP.ini settings
1832
# see https://secure.php.net/manual/en/opcache.installation.php

php7.0/fpm/Dockerfile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@ FROM php:7.0-fpm
22

33
# install the PHP extensions we need
44
RUN set -ex; \
5+
\
6+
savedAptMark="$(apt-mark showmanual)"; \
57
\
68
apt-get update; \
7-
apt-get install -y \
9+
apt-get install -y --no-install-recommends \
810
libjpeg-dev \
911
libpng-dev \
1012
; \
11-
rm -rf /var/lib/apt/lists/*; \
1213
\
1314
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
14-
docker-php-ext-install gd mysqli opcache
15-
# TODO consider removing the *-dev deps and only keeping the necessary lib* packages
15+
docker-php-ext-install gd mysqli opcache; \
16+
\
17+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
18+
apt-mark auto '.*' > /dev/null; \
19+
apt-mark manual $savedAptMark; \
20+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
21+
| awk '/=>/ { print $3 }' \
22+
| sort -u \
23+
| xargs -r dpkg-query -S \
24+
| cut -d: -f1 \
25+
| sort -u \
26+
| xargs -rt apt-mark manual; \
27+
\
28+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
29+
rm -rf /var/lib/apt/lists/*
1630

1731
# set recommended PHP.ini settings
1832
# see https://secure.php.net/manual/en/opcache.installation.php

php7.1/apache/Dockerfile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@ FROM php:7.1-apache
22

33
# install the PHP extensions we need
44
RUN set -ex; \
5+
\
6+
savedAptMark="$(apt-mark showmanual)"; \
57
\
68
apt-get update; \
7-
apt-get install -y \
9+
apt-get install -y --no-install-recommends \
810
libjpeg-dev \
911
libpng-dev \
1012
; \
11-
rm -rf /var/lib/apt/lists/*; \
1213
\
1314
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
14-
docker-php-ext-install gd mysqli opcache
15-
# TODO consider removing the *-dev deps and only keeping the necessary lib* packages
15+
docker-php-ext-install gd mysqli opcache; \
16+
\
17+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
18+
apt-mark auto '.*' > /dev/null; \
19+
apt-mark manual $savedAptMark; \
20+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
21+
| awk '/=>/ { print $3 }' \
22+
| sort -u \
23+
| xargs -r dpkg-query -S \
24+
| cut -d: -f1 \
25+
| sort -u \
26+
| xargs -rt apt-mark manual; \
27+
\
28+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
29+
rm -rf /var/lib/apt/lists/*
1630

1731
# set recommended PHP.ini settings
1832
# see https://secure.php.net/manual/en/opcache.installation.php

php7.1/fpm/Dockerfile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@ FROM php:7.1-fpm
22

33
# install the PHP extensions we need
44
RUN set -ex; \
5+
\
6+
savedAptMark="$(apt-mark showmanual)"; \
57
\
68
apt-get update; \
7-
apt-get install -y \
9+
apt-get install -y --no-install-recommends \
810
libjpeg-dev \
911
libpng-dev \
1012
; \
11-
rm -rf /var/lib/apt/lists/*; \
1213
\
1314
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
14-
docker-php-ext-install gd mysqli opcache
15-
# TODO consider removing the *-dev deps and only keeping the necessary lib* packages
15+
docker-php-ext-install gd mysqli opcache; \
16+
\
17+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
18+
apt-mark auto '.*' > /dev/null; \
19+
apt-mark manual $savedAptMark; \
20+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
21+
| awk '/=>/ { print $3 }' \
22+
| sort -u \
23+
| xargs -r dpkg-query -S \
24+
| cut -d: -f1 \
25+
| sort -u \
26+
| xargs -rt apt-mark manual; \
27+
\
28+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
29+
rm -rf /var/lib/apt/lists/*
1630

1731
# set recommended PHP.ini settings
1832
# see https://secure.php.net/manual/en/opcache.installation.php

php7.2/apache/Dockerfile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@ FROM php:7.2-apache
22

33
# install the PHP extensions we need
44
RUN set -ex; \
5+
\
6+
savedAptMark="$(apt-mark showmanual)"; \
57
\
68
apt-get update; \
7-
apt-get install -y \
9+
apt-get install -y --no-install-recommends \
810
libjpeg-dev \
911
libpng-dev \
1012
; \
11-
rm -rf /var/lib/apt/lists/*; \
1213
\
1314
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
14-
docker-php-ext-install gd mysqli opcache
15-
# TODO consider removing the *-dev deps and only keeping the necessary lib* packages
15+
docker-php-ext-install gd mysqli opcache; \
16+
\
17+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
18+
apt-mark auto '.*' > /dev/null; \
19+
apt-mark manual $savedAptMark; \
20+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
21+
| awk '/=>/ { print $3 }' \
22+
| sort -u \
23+
| xargs -r dpkg-query -S \
24+
| cut -d: -f1 \
25+
| sort -u \
26+
| xargs -rt apt-mark manual; \
27+
\
28+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
29+
rm -rf /var/lib/apt/lists/*
1630

1731
# set recommended PHP.ini settings
1832
# see https://secure.php.net/manual/en/opcache.installation.php

php7.2/fpm/Dockerfile

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,31 @@ FROM php:7.2-fpm
22

33
# install the PHP extensions we need
44
RUN set -ex; \
5+
\
6+
savedAptMark="$(apt-mark showmanual)"; \
57
\
68
apt-get update; \
7-
apt-get install -y \
9+
apt-get install -y --no-install-recommends \
810
libjpeg-dev \
911
libpng-dev \
1012
; \
11-
rm -rf /var/lib/apt/lists/*; \
1213
\
1314
docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \
14-
docker-php-ext-install gd mysqli opcache
15-
# TODO consider removing the *-dev deps and only keeping the necessary lib* packages
15+
docker-php-ext-install gd mysqli opcache; \
16+
\
17+
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
18+
apt-mark auto '.*' > /dev/null; \
19+
apt-mark manual $savedAptMark; \
20+
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
21+
| awk '/=>/ { print $3 }' \
22+
| sort -u \
23+
| xargs -r dpkg-query -S \
24+
| cut -d: -f1 \
25+
| sort -u \
26+
| xargs -rt apt-mark manual; \
27+
\
28+
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
29+
rm -rf /var/lib/apt/lists/*
1630

1731
# set recommended PHP.ini settings
1832
# see https://secure.php.net/manual/en/opcache.installation.php

0 commit comments

Comments
 (0)