Php: PHP 7.2.14-fpm-alpine not building with Imagick

Created on 8 Feb 2019  路  3Comments  路  Source: docker-library/php

Our travis builds started failing today, after the update to php 7.2.14.

This is the error message from the build

...
checking whether to enable the imagick extension... yes, shared
checking for pkg-config... /usr/bin/pkg-config
checking ImageMagick MagickWand API configuration program... checking Testing /usr/local/bin/MagickWand-config... Doesn't exist
checking Testing /usr/bin/MagickWand-config... Doesn't exist
checking Testing /usr/sbin/bin/MagickWand-config... Doesn't exist
checking Testing /opt/bin/MagickWand-config... Doesn't exist
checking Testing /opt/local/bin/MagickWand-config... Doesn't exist
configure: error: not found. Please provide a path to MagickWand-config or Wand-config program.
ERROR: `/tmp/pear/temp/imagick/configure --with-php-config=/usr/local/bin/php-config --with-imagick' failed
...

Below is our Dockerfile when it was failing. When we updated to
FROM php:7.2.13-fpm-alpine as fpm_base
the builds started passing again.

FROM php:7.2-fpm-alpine as fpm_base

RUN apk add --no-cache --virtual .persistent-deps \
        git \
        icu-libs \
        zlib \
        openssh \
        imagemagick \
        imagemagick-libs \
        imagemagick-dev

ENV APCU_VERSION 5.1.8

RUN set -xe \
    && apk add --no-cache --virtual .build-deps \
        $PHPIZE_DEPS \
        icu-dev \
        zlib-dev \
    && docker-php-ext-install \
        intl \
        pdo_mysql \
        zip \
    && pecl install \
        apcu-${APCU_VERSION} \
        apcu_bc \
        imagick \
        redis \
    && docker-php-ext-enable --ini-name 20-apcu.ini apcu \
    && docker-php-ext-enable --ini-name 21-apc.ini apc \
    && docker-php-ext-enable --ini-name 05-opcache.ini opcache \
    && docker-php-ext-enable --ini-name 20-imagick.ini imagick \
    && docker-php-ext-enable --ini-name 20-redis.ini redis \
    && apk del .build-deps
Issue

Most helpful comment

I'm not sure why, but the --virtual .persistent-deps is the culprit and changing that to something like just --virtual .deps fixes the install issues.

The .persistent-deps is used by the base, but like you said it works fine in php 7.2.13, looking at the history I don't see any differences for the virtual package name in 7.2.13 and 7.2.14
Also you'll encounter an error with php in the container about unable to load dynamic library 'imagick.so' when deleting the .build-deps. I've removed the line deleting the .build-deps in my Dockerfile.

FROM php:7.2.14-fpm-alpine as fpm_base

RUN apk add --no-cache --virtual .deps \
                git \
                icu-libs \
                zlib \
                openssh \
                imagemagick \
                imagemagick-libs \
                imagemagick-dev

ENV APCU_VERSION 5.1.8

RUN set -xe \
        && apk add --no-cache --virtual .build-deps \
                $PHPIZE_DEPS \
                icu-dev \
                zlib-dev \
        && docker-php-ext-install \
                intl \
                pdo_mysql \
                zip \
        && pecl install \
                apcu-${APCU_VERSION} \
                apcu_bc \
                imagick \
                redis \
        && docker-php-ext-enable --ini-name 20-apcu.ini apcu \
        && docker-php-ext-enable --ini-name 21-apc.ini apc \
        && docker-php-ext-enable --ini-name 05-opcache.ini opcache \
        && docker-php-ext-enable --ini-name 20-imagick.ini imagick \
        && docker-php-ext-enable --ini-name 20-redis.ini redis
$ docker build . -t php:test
Sending build context to Docker daemon  1.266MB
Step 1/4 : FROM php:7.2.14-fpm-alpine as fpm_base
 ---> d2c3a5391db0
Step 2/4 : RUN apk add --no-cache --virtual .deps               git            icu-libs                 zlib            openssh                 imagemagick    imagemagick-libs                 imagemagick-dev
 ---> Using cache
 ---> 8afc94223026
Step 3/4 : ENV APCU_VERSION 5.1.8
 ---> Using cache
 ---> 63455e3dbccd
Step 4/4 : RUN set -xe  && apk add --no-cache --virtual .build-deps            $PHPIZE_DEPS             icu-dev                 zlib-dev        && docker-php-ext-install               intl            pdo_mysql               zip     && pecl install                 apcu-${APCU_VERSION}            apcu_bc                imagick          redis   && docker-php-ext-enable --ini-name 20-apcu.ini apcu   && docker-php-ext-enable --ini-name 21-apc.ini apc       && docker-php-ext-enable --ini-name 05-opcache.ini opcache      && docker-php-ext-enable --ini-name 20-imagick.ini imagick      && docker-php-ext-enable --ini-name 20-redis.ini redis
 ---> Using cache
 ---> 253ec19c49e2
Successfully built 253ec19c49e2
Successfully tagged php:test
$ docker run --rm php:test php -m | grep imagick
imagick

All 3 comments

I'm not sure why, but the --virtual .persistent-deps is the culprit and changing that to something like just --virtual .deps fixes the install issues.

The .persistent-deps is used by the base, but like you said it works fine in php 7.2.13, looking at the history I don't see any differences for the virtual package name in 7.2.13 and 7.2.14
Also you'll encounter an error with php in the container about unable to load dynamic library 'imagick.so' when deleting the .build-deps. I've removed the line deleting the .build-deps in my Dockerfile.

FROM php:7.2.14-fpm-alpine as fpm_base

RUN apk add --no-cache --virtual .deps \
                git \
                icu-libs \
                zlib \
                openssh \
                imagemagick \
                imagemagick-libs \
                imagemagick-dev

ENV APCU_VERSION 5.1.8

RUN set -xe \
        && apk add --no-cache --virtual .build-deps \
                $PHPIZE_DEPS \
                icu-dev \
                zlib-dev \
        && docker-php-ext-install \
                intl \
                pdo_mysql \
                zip \
        && pecl install \
                apcu-${APCU_VERSION} \
                apcu_bc \
                imagick \
                redis \
        && docker-php-ext-enable --ini-name 20-apcu.ini apcu \
        && docker-php-ext-enable --ini-name 21-apc.ini apc \
        && docker-php-ext-enable --ini-name 05-opcache.ini opcache \
        && docker-php-ext-enable --ini-name 20-imagick.ini imagick \
        && docker-php-ext-enable --ini-name 20-redis.ini redis
$ docker build . -t php:test
Sending build context to Docker daemon  1.266MB
Step 1/4 : FROM php:7.2.14-fpm-alpine as fpm_base
 ---> d2c3a5391db0
Step 2/4 : RUN apk add --no-cache --virtual .deps               git            icu-libs                 zlib            openssh                 imagemagick    imagemagick-libs                 imagemagick-dev
 ---> Using cache
 ---> 8afc94223026
Step 3/4 : ENV APCU_VERSION 5.1.8
 ---> Using cache
 ---> 63455e3dbccd
Step 4/4 : RUN set -xe  && apk add --no-cache --virtual .build-deps            $PHPIZE_DEPS             icu-dev                 zlib-dev        && docker-php-ext-install               intl            pdo_mysql               zip     && pecl install                 apcu-${APCU_VERSION}            apcu_bc                imagick          redis   && docker-php-ext-enable --ini-name 20-apcu.ini apcu   && docker-php-ext-enable --ini-name 21-apc.ini apc       && docker-php-ext-enable --ini-name 05-opcache.ini opcache      && docker-php-ext-enable --ini-name 20-imagick.ini imagick      && docker-php-ext-enable --ini-name 20-redis.ini redis
 ---> Using cache
 ---> 253ec19c49e2
Successfully built 253ec19c49e2
Successfully tagged php:test
$ docker run --rm php:test php -m | grep imagick
imagick

Got the same problem, when using

  • apk add --no-cache --virtual .persistent-deps libstdc++ libzip zlib
  • apk add --no-cache --virtual .build-deps $PHPIZE_DEPS libzip-dev zlib-dev

Later when the virtual package .build-deps is removed with apk del .build-deps it also remove packages from .persistent-deps.

  • (1/28) Purging .build-deps (0)
  • (2/28) Purging autoconf (2.69-r2)
  • (3/28) Purging m4 (1.4.18-r1)
  • (4/28) Purging dpkg-dev (1.19.2-r0)
  • (5/28) Purging perl (5.26.3-r0)
  • (6/28) Purging dpkg (1.19.2-r0)
  • (7/28) Purging file (5.35-r0)
  • (8/28) Purging g++ (8.2.0-r2)
  • (9/28) Purging gcc (8.2.0-r2)
  • (10/28) Purging binutils (2.31.1-r2)
  • (11/28) Purging libatomic (8.2.0-r2)
  • (12/28) Purging libgomp (8.2.0-r2)
  • (13/28) Purging libc-dev (0.7.1-r0)
  • (14/28) Purging musl-dev (1.1.20-r3)
  • (15/28) Purging make (4.2.1-r2)
  • (16/28) Purging re2c (1.1.1-r0)
  • (17/28) Purging libzip-dev (1.5.1-r2)
  • __(18/28) Purging libzip (1.5.1-r2)__
  • (19/28) Purging zlib-dev (1.2.11-r1)
  • (20/28) Purging libbz2 (1.0.6-r6)
  • (21/28) Purging pkgconf (1.6.0-r0)
  • (22/28) Purging libmagic (5.35-r0)
  • __(23/28) Purging libstdc++ (8.2.0-r2)__
  • (24/28) Purging libgcc (8.2.0-r2)
  • (25/28) Purging mpc1 (1.0.3-r1)
  • (26/28) Purging mpfr3 (3.1.5-r1)
  • (27/28) Purging isl (0.18-r0)
  • (28/28) Purging gmp (6.1.2-r1)

Renaming .persistent-deps to .deps as @wglambert suggested ahead, and apk stopped removing the packages libzip and libstdc++.

I don't understand why it starts breaking when upgrading to PHP 7.3.2. Is it related to Alpine being updated to v3.9?

It looks like https://bugs.alpinelinux.org/issues/9651 is a bug with apk 2.10.3.
So php:7.2.13 uses apk 2.10.1 and doesn't encounter this.

$ docker run --rm php:7.2.13-fpm-alpine apk --version
apk-tools 2.10.1, compiled for x86_64.

$ docker run --rm php:7.2.14-fpm-alpine apk --version
apk-tools 2.10.3, compiled for x86_64.
Was this page helpful?
0 / 5 - 0 ratings