phpaddmod = very large build size #183
Replies: 3 comments
-
There are many best practices for optimizing the file size of Docker images. These include running all commands like In your case, consider combining the two RUN instructions into one using &&, and finally, add commands to remove unnecessary packages to reduce the image size. If this is too challenging, you might consider using my docker-squash utility to reduce the size of your Docker images without having to strictly adhere to Dockerfile best practices. The Docker images I provide are built based on the official PHP Docker images, which currently only support Alpine Linux and Debian variants. I’m not sure what you’re trying to install from sury.org, but it seems those packages are intended for Ubuntu and may not be compatible. I believe this isn’t an issue with your Dockerfile but rather a compatibility issue between the packages provided by the official PHP Docker images and those from sury.org. |
Beta Was this translation helpful? Give feedback.
-
@shinsenter thanks for commenting. The thing is : imagick and bz2 belong to the list of recommended wordpress modules that many plugins use and that are checked by site health module. I need it and so I checked your wordpress images, too, btw, but they have the same modules as your php images, and imagick and bz2 are not included. The base php images explicitly exclude installing php stuff from repos in /etc/apt/preferences.d/no-debian-php. This might have good reasons and so I won't override it - also there are no packages on debian for older php versions like 8.1. For the official php docker images, docker-php-ext-install is recommended, but you surely had good reasons to disable this since your image setup is quite complex :-) The bottom line - I will now move the module installation with your phpaddmod tool up early in the docker file and rely on whatever caching the docker environment applies where the build is executed. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your feedback. I believe pre-installing a large module like |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
after trying to build a good apache-fpm environment for Wordpress (and failing :-) ) I am now trying to customize and use your very helpful images. However I need to add some php modules, and according to the docs (and my own experiments) neither docker-php-ext-install and apt-get can be used to integrate those in the container's php enviroment .
So I used
RUN phpaddmod imagick bz2
in my Dockerfile, with the result that the build size went up from 550 to 850 MB, and the build time also significantly increases. This is sort of defeating the purpose of using your optimized images that are so small even with all the helpful stuff in them.
I thought about removing the build tools with apt after the installation, but that would not solve the build time increase and the amount of data being transferred from debian repos during every build. Is there any other way to get extensions in binary form from existing repos like from sury.org?
Currently , my dockerfile is like this:
Would it help to move the phpaddmod call to an early stage in the Dockerfile to have the results cached by docker for subsequent builds of this image?
Regards,
Ulrich
Beta Was this translation helpful? Give feedback.
All reactions