diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index 161b5e71a4..edd9dd688b 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -2,17 +2,31 @@ FROM php:%%PHP_VERSION%%-%%VARIANT%% # install the PHP extensions we need RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ - apt-get install -y \ + apt-get install -y --no-install-recommends \ libjpeg-dev \ libpng-dev \ ; \ - rm -rf /var/lib/apt/lists/*; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ - docker-php-ext-install gd mysqli opcache -# TODO consider removing the *-dev deps and only keeping the necessary lib* packages + docker-php-ext-install gd mysqli opcache; \ + \ +# 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 diff --git a/php5.6/apache/Dockerfile b/php5.6/apache/Dockerfile index 5abb3fd489..5ff9e011c2 100644 --- a/php5.6/apache/Dockerfile +++ b/php5.6/apache/Dockerfile @@ -2,17 +2,31 @@ FROM php:5.6-apache # install the PHP extensions we need RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ - apt-get install -y \ + apt-get install -y --no-install-recommends \ libjpeg-dev \ libpng-dev \ ; \ - rm -rf /var/lib/apt/lists/*; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ - docker-php-ext-install gd mysqli opcache -# TODO consider removing the *-dev deps and only keeping the necessary lib* packages + docker-php-ext-install gd mysqli opcache; \ + \ +# 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 diff --git a/php5.6/fpm/Dockerfile b/php5.6/fpm/Dockerfile index 0f4e89c351..182b1cc7c4 100644 --- a/php5.6/fpm/Dockerfile +++ b/php5.6/fpm/Dockerfile @@ -2,17 +2,31 @@ FROM php:5.6-fpm # install the PHP extensions we need RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ - apt-get install -y \ + apt-get install -y --no-install-recommends \ libjpeg-dev \ libpng-dev \ ; \ - rm -rf /var/lib/apt/lists/*; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ - docker-php-ext-install gd mysqli opcache -# TODO consider removing the *-dev deps and only keeping the necessary lib* packages + docker-php-ext-install gd mysqli opcache; \ + \ +# 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 diff --git a/php7.0/apache/Dockerfile b/php7.0/apache/Dockerfile index 13f3624949..5dffd476ee 100644 --- a/php7.0/apache/Dockerfile +++ b/php7.0/apache/Dockerfile @@ -2,17 +2,31 @@ FROM php:7.0-apache # install the PHP extensions we need RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ - apt-get install -y \ + apt-get install -y --no-install-recommends \ libjpeg-dev \ libpng-dev \ ; \ - rm -rf /var/lib/apt/lists/*; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ - docker-php-ext-install gd mysqli opcache -# TODO consider removing the *-dev deps and only keeping the necessary lib* packages + docker-php-ext-install gd mysqli opcache; \ + \ +# 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 diff --git a/php7.0/fpm/Dockerfile b/php7.0/fpm/Dockerfile index 5001e76b39..eabe7e1369 100644 --- a/php7.0/fpm/Dockerfile +++ b/php7.0/fpm/Dockerfile @@ -2,17 +2,31 @@ FROM php:7.0-fpm # install the PHP extensions we need RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ - apt-get install -y \ + apt-get install -y --no-install-recommends \ libjpeg-dev \ libpng-dev \ ; \ - rm -rf /var/lib/apt/lists/*; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ - docker-php-ext-install gd mysqli opcache -# TODO consider removing the *-dev deps and only keeping the necessary lib* packages + docker-php-ext-install gd mysqli opcache; \ + \ +# 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 diff --git a/php7.1/apache/Dockerfile b/php7.1/apache/Dockerfile index dc2391561d..3a75f2f1af 100644 --- a/php7.1/apache/Dockerfile +++ b/php7.1/apache/Dockerfile @@ -2,17 +2,31 @@ FROM php:7.1-apache # install the PHP extensions we need RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ - apt-get install -y \ + apt-get install -y --no-install-recommends \ libjpeg-dev \ libpng-dev \ ; \ - rm -rf /var/lib/apt/lists/*; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ - docker-php-ext-install gd mysqli opcache -# TODO consider removing the *-dev deps and only keeping the necessary lib* packages + docker-php-ext-install gd mysqli opcache; \ + \ +# 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 diff --git a/php7.1/fpm/Dockerfile b/php7.1/fpm/Dockerfile index 74f3d84c14..a9e2678fa1 100644 --- a/php7.1/fpm/Dockerfile +++ b/php7.1/fpm/Dockerfile @@ -2,17 +2,31 @@ FROM php:7.1-fpm # install the PHP extensions we need RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ - apt-get install -y \ + apt-get install -y --no-install-recommends \ libjpeg-dev \ libpng-dev \ ; \ - rm -rf /var/lib/apt/lists/*; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ - docker-php-ext-install gd mysqli opcache -# TODO consider removing the *-dev deps and only keeping the necessary lib* packages + docker-php-ext-install gd mysqli opcache; \ + \ +# 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 diff --git a/php7.2/apache/Dockerfile b/php7.2/apache/Dockerfile index 6c9b08927b..904b897f48 100644 --- a/php7.2/apache/Dockerfile +++ b/php7.2/apache/Dockerfile @@ -2,17 +2,31 @@ FROM php:7.2-apache # install the PHP extensions we need RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ - apt-get install -y \ + apt-get install -y --no-install-recommends \ libjpeg-dev \ libpng-dev \ ; \ - rm -rf /var/lib/apt/lists/*; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ - docker-php-ext-install gd mysqli opcache -# TODO consider removing the *-dev deps and only keeping the necessary lib* packages + docker-php-ext-install gd mysqli opcache; \ + \ +# 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 diff --git a/php7.2/fpm/Dockerfile b/php7.2/fpm/Dockerfile index 1115254306..89d27e020c 100644 --- a/php7.2/fpm/Dockerfile +++ b/php7.2/fpm/Dockerfile @@ -2,17 +2,31 @@ FROM php:7.2-fpm # install the PHP extensions we need RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ - apt-get install -y \ + apt-get install -y --no-install-recommends \ libjpeg-dev \ libpng-dev \ ; \ - rm -rf /var/lib/apt/lists/*; \ \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr; \ - docker-php-ext-install gd mysqli opcache -# TODO consider removing the *-dev deps and only keeping the necessary lib* packages + docker-php-ext-install gd mysqli opcache; \ + \ +# 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