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.
/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:
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.
Most helpful comment
yes, I mean, once we have installed the dependencies, we could remove it too (not use at run-time).