L
L
l4m3r2019-03-26 00:25:30
PHP
l4m3r, 2019-03-26 00:25:30

Why is adding extensions to PHP so...difficult?

Newbie questions, but still. Here is a typical Dockerfile that I ended up with:

FROM php:7.3-fpm-alpine
RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS git \
            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 intl json curl iconv \
    && 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 in order to install a banal extension, you need to re-download a bunch of $PHPIZE_DEPS, which have already been downloaded and removed in the base image. Redundancy 100500, as for me.
2. Is there any adequate description of how to correctly add each extension to alpine?
So, for example, it was written that in order to add gd, you need to put such and such dependencies (libpng, libjpeg, ...) and do docker-php-ext-configure. To intl, you need to install libicu-dev. Etc. That xdebug should be added by pecl. And so on for the rest of the main modules.
With such a hassle, sometimes you want to score on alpine, do FROM ubuntu and apt install php-xdebug php-mysql php-gd ...

Answer the question

In order to leave comments, you need to log in

4 answer(s)
O
OnYourLips, 2019-03-26
@OnYourLips

With such a hassle, sometimes you want to score on alpine, do FROM ubuntu and apt install php-xdebug php-mysql php-gd
If it suits your task better, then why not do it?
If you are afraid of a large amount of space occupied, then inherit all your images from one base image, this volume will be occupied only once (several, in the case of different versions of the base image, but this is later).
Roughly speaking, if you are bringing your package to the masses, use alpine so as not to strain users. If you use internally - then "FROM my-repo / ubuntu"

H
HEKET313, 2019-03-26
@HEKET313

I did some assembly on alpine, and then it turned out that there is no pdo driver for working with mssql on alpine and is not planned. I had to redo everything to the familiar and supported by all ubuntu.

B
Bogdan Kondratov, 2020-07-22
@KondorB

I understand that the question has already grown a meter beard, but nevertheless, maybe someone will accidentally google it and my three kopecks will help:
There is a community project - a script for automatically installing PHP extensions inside Docker images.
It downloads dependencies by itself, correctly configures extensions and cleans up unnecessary packages after installation, here:
https://github.com/mlocati/docker-php-extension-in...

A
Anton Shamanov, 2019-03-26
@SilenceOfWinter

you haven’t seen a ruby ​​with java yet, there you would have had an apoplectic stroke)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question