PHP base images have large size #362
|
Hey, thanks for this amazing project! Why is the PHP image so large (1.3 GB)? Is this normal? I expected PHP images to be smaller, around a few hundred MB. this is the output of |
Replies: 1 comment 1 reply
|
good catch on the size, you're right it's on the high end. the bulk of it is the build toolchain (autoconf, make, g++, linux headers, and the long list of -dev packages) plus all the runtime extras the image carries by default, ImageMagick, Ghostscript, ffmpeg, node and npm, the new zsh shell stuff, plus around 30 PHP extensions including imagick, redis, mongodb, igbinary, pcov, xdebug. the toolchain alone is roughly 800MB because everything sits in a single RUN layer, so once pecl is done compiling the .so files the headers and compilers don't get dropped. I just put up PR #364 that splits the Containerfile into a builder and a runtime stage, the toolchain stays in the builder and only the compiled .so files plus the runtime libs land in the final image. on PR #358's base that takes localhost/lerd-php85-fpm from 1.36 GB down to 535 MB, around 60 percent off, with the same set of extensions loading and composer, node, npm, ghostscript, imagemagick, ffmpeg, mysql client and zsh all still there. custom extensions like imap keep working too because their apk runtime deps get reinstalled in the runtime stage. if you want to try it locally before it lands you can check out the slim/php-image-on-358 branch and run lerd php:rebuild --local, the --local flag bypasses the pre-built base image pull. once #358 and #364 ship the pre-built ghcr base image will get republished at the new size so existing users pick it up on the next 24h refresh. |
good catch on the size, you're right it's on the high end. the bulk of it is the build toolchain (autoconf, make, g++, linux headers, and the long list of -dev packages) plus all the runtime extras the image carries by default, ImageMagick, Ghostscript, ffmpeg, node and npm, the new zsh shell stuff, plus around 30 PHP extensions including imagick, redis, mongodb, igbinary, pcov, xdebug. the toolchain alone is roughly 800MB because everything sits in a single RUN layer, so once pecl is done compiling the .so files the headers and compilers don't get dropped.
I just put up PR #364 that splits the Containerfile into a builder and a runtime stage, the toolchain stays in the builder and only t…