Why add extensions to PHP is ... complicated?

Newbie questions, but still. Here is a typical Dockerfile that I got:
FROM php:7.3-fpm-alpine
RUN apk add --no-cache --virtual .build-deps $git PHPIZE_DEPS \
 imagemagick \
 imagemagick-dev \
 freetype-dev \
 libjpeg-turbo-dev \
 libpng-dev \
 && pecl install xdebug imagick \
 && docker-php-ext-enable xdebug \
 && docker-php-ext-enable imagick \
 && docker-php-ext-install-j$(nproc) pdo_mysql curl iconv intl json \
 && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
 && docker-php-ext-install-j$(nproc) gd \
 && apk del -f .build-deps \
 && ln-sf "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"

1. It turns out that to put a trivial extension, we must re-pump a bunch of $PHPIZE_DEPS that have already been downloaded and deleted in the base image. Redundancy 100500 to me.

2. Is there any adequate description of how to correctly add each extension in alpine?
For example, it was written that to add the gd, you need to put these dependencies (libpng, libjpeg, ...) and make the docker-php-ext-configure. To intl, you need to put libicu-dev. Etc xdebug must pecl'om add. And so on the remaining main modules.

Such crap, sometimes you want to score on Alta, to do FROM ubuntu and apt install php-xdebug php-mysql php-gd ...
March 19th 20 at 08:34
3 answers
March 19th 20 at 08:36
Such crap, sometimes you want to score on Alta, to do FROM ubuntu and apt install php-xdebug php-mysql php-gd
If it is better suited for your task, then why not do it?
If you are afraid of a large volume of space, then derive all your images from one base, this volume will be occupied only once (several, if different versions of the base image, but that would come later).

Roughly speaking, if you carry your package to the masses - use alpine to not strain the user. If used inside the company - that "FROM my-repo/ubuntu"
Well, to be honest, I leaf through github and see that often in Ubuntu too yuzayut all these install the -dev libraries and configuration compilation.
What do this approach is better than the banal ready to install package install php-xxx? A couple of percent faster then the script is executed? - davion75 commented on March 19th 20 at 08:39
@davion75, collect fruits when you use a non-standard binary dependencies, such as pcre or openssl with the patch. - annie85 commented on March 19th 20 at 08:42
March 19th 20 at 08:38
Did I somehow build on alpine, but then it turned out that on alpine pdo driver for work with mssql there are no plans. Had to redo things and all supported ubuntu.
March 19th 20 at 08:40
did you even ruby with Java is not seen, there would you stroke enough)
:) I just some kind of uniform documentation to find. And so... that made the docker-php-ext-install intl. Got error when build the image. I started to Google. It turns out that people in some ancient issue on github pointed out that we need a library xxx to put. - davion75 commented on March 19th 20 at 08:43
@davion75, with official extensions from hell problems are not met, but not exotic, I put only phpui - Garth.Walsh17 commented on March 19th 20 at 08:46
@davion75, the problem is that is it's not in the default build where all of this goes out of the box, and on top of Alta, which was designed to be initially empty, without any additional shit. And of course all the manuals are mostly initially for any debian-based OSes.

PS Plus only in recent years mainly prefer pure cli/fpm, but if you install Apache (php apache package ie) installer puts do it all at once, almost like under Windows, where all popular extensions out of the box go (I think, could be wrong). In this, the manuals have not quite adapted. - Lydia.Streich commented on March 19th 20 at 08:49

Find more questions by tags DockerPHP