Php: Remove build dependencies after docker-php-ext-install

Created on 4 Jan 2018  路  4Comments  路  Source: docker-library/php

Since removing build dependencies after installing PHP extensions (e.g. https://github.com/docker-library/wordpress/pull/267) seems to be a common task it would make sense to have such a functionality in the docker-php-ext-* scripts.

Request

Most helpful comment

yes, I mean, once we have installed the dependencies, we could remove it too (not use at run-time).

All 4 comments

/usr/src/php.tar.xz can be removed too ?

docker run --rm php:7.2.5-cli-alpine3.7 ls -alh /usr/src => 11.5M (16% of the total image size)

Nope, that is used here.

yes, I mean, once we have installed the dependencies, we could remove it too (not use at run-time).

As for deleting the source, that would be a duplicate of #488.

For auto-removing build dependencies that we add, that is done in the Alpine images:

https://github.com/docker-library/php/blob/40176806407cec87a3d253067e83d2d0ceb2664d/docker-php-ext-install#L116-L118

We don't auto-add build dependencies in Debian since any needed for phpize are already installed. See https://github.com/docker-library/php/issues/513#issuecomment-340551339 and #438 for why we don't auto add/remove packages in Debian.

As for any other dependencies that could be installed in a Dockerfile, since we didn't add them, we can't reasonably detect that they can be removed.

Was this page helpful?
0 / 5 - 0 ratings