composer / docker

Composer in Docker

Home Page:https://hub.docker.com/_/composer/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Composer 2.6 with PHP 8.3.0 difficulty building gd extension

phpguru opened this issue · comments

As this link shows:
https://pkgs.alpinelinux.org/packages?name=php83-gd&branch=edge&repo=&arch=&maintainer=
Until php83-gd is available there, I don't know how it works.

We had a lot of challenges compiling gd extension on php8.3 alpine with composer base image.

0.036 Warning: PHP Startup: Unable to load dynamic library 'gd.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20230831/gd.so (Error loading shared library libpng16.so.16: No such file or directory (needed by /usr/local/lib/php/extensions/no-debug-non-zts-20230831/gd.so)), /usr/local/lib/php/extensions/no-debug-non-zts-20230831/gd.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20230831/gd.so.so: No such file or directory)) in Unknown on line 0

Even using --with-png=/usr/include it gives an error unrecognized option --with-png

This works for me:

FROM composer:2.6
... 

RUN apk add --virtual build-dependencies --no-cache autoconf gcc g++ make freetype-dev zlib-dev libpng-dev libjpeg-turbo-dev libmcrypt-dev openssl ca-certificates libxml2-dev oniguruma-dev

RUN docker-php-ext-configure gd --enable-gd --with-freetype=/usr/include/freetype2/ --with-jpeg=/usr/include/
RUN docker-php-ext-install gd
RUN docker-php-ext-enable gd

Thought I would leave this here for others in the future.

Refs:

commented

I would like to point out that our documentation also explicitly states our images should not be used as a base image. You can choose to ignore this, of course. But we simply do not support it because of all the various scenarios we would have to take into account.