- Issue created by @andypost
- @andypost opened merge request.
- 🇫🇷France andypost
Also upgraded APCu to https://pecl.php.net/package-changelog.php?package=APCu&release=5.1.22 as support for 8.2 added here
- 🇫🇷France andypost
Current amount of layers is 37, after fix 31
also removal of source code cleans up >200MB
/bin/sh -c set -xe && buildDeps=" a… 657MB
after
RUN /bin/sh -c set -xe && buildDeps=" … 439MB
Also instead of build dependencies for production it could use fixed set of libraries (instead of -dev) so this layer could become smaller
- Status changed to Needs review
over 1 year ago 1:26am 17 September 2023 -
andypost →
committed bb749b0b on dev
Minimize PHP 8.2 image size #3387737
-
andypost →
committed bb749b0b on dev
- 🇫🇷France andypost
The pipeline using new image https://git.drupalcode.org/issue/drupal-3315265/-/pipelines/20801
- 🇫🇷France andypost
https://hub.docker.com/r/drupalci/php-8.2-apache/tags in zipped format CI will download 465MB instead of 504M and unpacking will eat less CPU
-
andypost →
committed 5e68608e on dev
Add php-82-cli image #3387737
-
andypost →
committed 5e68608e on dev
-
andypost →
committed b268efff on dev
Add node and yarn to php-82-cli image #3387737
-
andypost →
committed b268efff on dev
- 🇫🇷France andypost
Current layers unpacked (via
docker history
)- PHP binaries - 152MB (could be minimized further by stripping debug symbols from binaries)
- libraries to run PHP - 175MB
- Nodejs with yarn - 187MBDownload sizes are
https://hub.docker.com/r/drupalci/php-8.2-apache/tags
- production - 504.88 MB
- dev image using cleanu-up - 465.43 MB after https://git.drupalcode.org/project/drupalci_environments/-/commit/bb749b...https://hub.docker.com/r/drupalci/php-8.2-cli/tags
- no yarn&node - 135 MB
- php + node/yarn - 189.93 MBPS: removed building
php-cgi
andphp-dbg
as unused -
andypost →
committed 695ee9a9 on dev
php/8.2-cli: clean-up outdated options #3387737 - mysql, mcrypt and...
-
andypost →
committed 695ee9a9 on dev
- @andypost opened merge request.
-
andypost →
committed 9713d8f4 on dev
Minimize PHP 8.2 image size #3387737
-
andypost →
committed 9713d8f4 on dev
-
andypost →
committed 9e9f89dc on slim
Minimize apache-8.2 image #3387737
-
andypost →
committed 9e9f89dc on slim
-
andypost →
committed 9713d8f4 on slim
Minimize PHP 8.2 image size #3387737
-
andypost →
committed 9713d8f4 on slim
-
andypost →
committed 9e9f89dc on dev
Minimize apache-8.2 image #3387737
-
andypost →
committed 9e9f89dc on dev
- 🇷🇺Russia walkingdexter
Most likely, the above changes are the cause of the problem described below.
Installation of additional PHP extensions via mlocati/docker-php-extension-installer (easy installation of extensions with their deps) fails with an error when using the image
drupalci/php-8.2-apache:production
.tar (child): /usr/src/php.tar.xz: Cannot open: No such file or directory tar (child): Error is not recoverable: exiting now tar: Child returned status 2 tar: Error is not recoverable: exiting now
The error doesn't occur when using images
drupalci/php-8.0-apache:production
,drupalci/php-8.1-apache:production
anddrupalci/php-8.2-apache:production-old
.I'm not sure if this is the appropriate place for this problem. However, someone may encounter the same error when setting up a GitLab CI configuration for their contrib project, which requires the installation of additional PHP extensions.
Thanks!
- 🇫🇷France andypost
Yes, that's right place to report it. Meantime the error points out that the script attempted to extract php source code vut that's wrong action - instead of rebuilding PHP itself it should use installed headers instead.
Moreover the most probably you'll need extra headers for pecl extension to build so it's not enough to just call a common script.Contrib willing to install something must care about how to build this extras as the debian base image for different php versions vary
- 🇷🇺Russia walkingdexter
Meantime the error points out that the script attempted to extract php source code vut that's wrong action - instead of rebuilding PHP itself it should use installed headers instead.
As I can see in the install-php-extensions script the error comes from
docker-php-source extract
(standard utility in official PHP images). PHP sources are used only to get the list of bundled extensions.Contrib willing to install something must care about how to build this extras as the debian base image for different php versions vary
The
install-php-extensions
script already supports a variety of Debian-based and Alpine-based images, as well as various PHP versions. Until recently it was a good solution to install PHP extensions (without additional overhead) in drupalci images too.Is it possible to revert the change that deletes the
/usr/src/php.tar.xz
file? Or it's a major change and it's not for discussion? Some other useful scripts compatible with PHP-based images may rely ondocker-php-source extract
, and the above change may break them too. - 🇫🇷France andypost
This scripts are supposed to build php from very limited base php one
but in CI we ship preconfigured for core/contrib needs
there's https://git.drupalcode.org/project/drupalci_environments/-/blob/dev/php/...It installs compiler and using pecl to build
- 🇷🇺Russia walkingdexter
Maybe this information will be useful.
The recommended approach to installing PHP extensions from GitLab CI guide → doesn't work with
drupalci/php-8.2-apache:production
.MongoDB example:
$ pecl install mongodb WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update downloading mongodb-1.17.2.tgz ... Starting to download mongodb-1.17.2.tgz (2,064,433 bytes) ......................................................................................................................................................................................................................................................................................................................................................................................................................done: 2,064,433 bytes 846 source files, building running: phpize Configuring for: PHP Api Version: 20220829 Zend Module Api No: 20220829 Zend Extension Api No: 420220829 Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF environment variable. Then, rerun this script. ERROR: `phpize' failed
I also don't see any option to install a bundled PHP extension. For example,
imap
is available in pecl only since PHP 8.3. - 🇫🇷France andypost
Just checked scripts - they are broken because using
apk
(Alpinelinux based package manager) instead ofapt
so it just needs to fix scripsATM you can add following to install build deps
apt-get install $PHPIZE_DEPS
- 🇫🇷France andypost
Sadly the same issue with official images https://github.com/docker-library/php/blob/master/8.3/bullseye/apache/do...
- 🇫🇷France andypost
As script to enable extensions is fixed (in 8.3 images ATM)
It's recommended to use following commands to install extra PECL extensions
- apt-get update && apt-get install -qy --no-install-recommends $PHPIZE_DEPS - pecl install mongodb && docker-php-ext-enable mongodb
-
andypost →
committed 7821c011 on dev
Minimize php:8.1-apache-8.1 #3387737
-
andypost →
committed 7821c011 on dev
-
andypost →
committed a3c320c1 on dev
Minimize php:8.1-apache image #3387737
-
andypost →
committed a3c320c1 on dev
-
andypost →
committed ef50be07 on dev
Minimize php:8.1-apache image #3387737
-
andypost →
committed ef50be07 on dev
-
andypost →
committed 9d3272a0 on dev
Minimize php:8.1-apache image #3387737
-
andypost →
committed 9d3272a0 on dev
-
andypost →
committed a9f73cf8 on dev
Minimize php:8.1-apache image #3387737
-
andypost →
committed a9f73cf8 on dev
-
andypost →
committed 07e9eb1a on dev
Minimize php:8.1-apache image #3387737
-
andypost →
committed 07e9eb1a on dev
-
andypost →
committed af524f81 on dev
Minimize php:8.1-apache image #3387737
-
andypost →
committed af524f81 on dev
- 🇫🇷France andypost
Polished PHP 8.1 image, now testing
drupalci/php-8.1-apache dev fdf0ce19de4e 21 minutes ago 681MB drupalci/php-8.1-apache <none> eb25b116360c 6 hours ago 1.36GB
-
andypost →
committed 57bc0228 on dev
Modernize 8.2-8.3 images #3387737 and #3108643
-
andypost →
committed 57bc0228 on dev
- 🇫🇷France andypost
Created change record → and gonna cherry-pick commits to production
-
andypost →
committed 5c0009b5 on production
Modernize 8.2-8.3 images #3387737 and #3108643 (cherry picked from...
-
andypost →
committed 5c0009b5 on production
-
andypost →
committed 82851eb6 on production
Minimize php:8.1-apache image #3387737 (cherry picked from commit...
-
andypost →
committed 82851eb6 on production
-
andypost →
committed 9eb10fb6 on production
Modernize 8.2-8.3 images #3387737 and #3108643 (cherry picked from...
-
andypost →
committed 9eb10fb6 on production
-
andypost →
committed c8d4da92 on production
Minimize php:8.1-apache image #3387737 (cherry picked from commit...
-
andypost →
committed c8d4da92 on production
- 🇯🇵Japan ptmkenny
Coming from Slack, I'm adding a quick note here that it would be great to find an easier way to use bundled PHP extensions like sodium. For example, lcobucci/jwt requires sodium, and several Drupal modules depend on this package (e.g., jwt, firebase).
Hopefully we can find a way to test them on an official PHP image.
- 🇫🇷France andypost
Thanks! That's another reason to have a base build of php image to produce from it shared extensions for sodium and others