Docker: php:8.1.1-fpm-alpine Install specific GD version

7.6k views Asked by At

Is there any way to specify installed GD extension version? Currently I have following Dockerfile:

ARG PHP_VERSION=8.1.1

FROM php:${PHP_VERSION}-fpm-alpine

RUN apk add --update --no-cache freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev libwebp-dev \
    && docker-php-ext-configure gd \
    --with-freetype \
    --with-jpeg \
    --with-webp \
    NPROC=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || 1) \
    && docker-php-ext-install -j$(nproc) gd \
    && apk del --no-cache freetype-dev libpng-dev libjpeg-turbo-dev \
    && mkdir /var/lib/php  \
    && chown www-data:www-data /var/lib/php -R


COPY php/conf.d/php.ini $PHP_INI_DIR/conf.d/php.ini
COPY php/conf.d/php-cli.ini $PHP_INI_DIR/conf.d/php-cli.ini

CMD ["php-fpm"]

However from results of this command:

php -r "print_r(gd_info());"

I can see that the installed GD version is 2.1.0:

Array
(
    [GD Version] => bundled (2.1.0 compatible)
    [FreeType Support] => 1
    [FreeType Linkage] => with freetype
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPEG Support] => 1
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] =>
    [XBM Support] => 1
    [WebP Support] => 1
    [BMP Support] => 1
    [AVIF Support] =>
    [TGA Read Support] => 1
    [JIS-mapped Japanese Font Support] =>
)

From the official GD documentation I can see that the version 2.1.0 is outdated not supported anymore and the current stable version is 2.3.3.

0

There are 0 answers