Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[alpine] imagick-3.5.0 can't be load into PHP without $PHPIZE_DEPS #1173

Closed
marxangels opened this issue Jun 27, 2021 · 4 comments
Closed

[alpine] imagick-3.5.0 can't be load into PHP without $PHPIZE_DEPS #1173

marxangels opened this issue Jun 27, 2021 · 4 comments
Labels

Comments

@marxangels
Copy link

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

It says imagick.so: No such file or directory, but the file is there.
After rollback to my previous version, imagick-3.4.4 , everything is ok.

@marxangels
Copy link
Author

apk add $PHPIZE_DEPS && \    
    apk add --virtual .imagick-deps imagemagick imagemagick-dev && \
    pecl install redis && \
    pecl install xdebug && \    
    pecl install imagick-3.4.4 && \
    pecl install igbinary && \    
    docker-php-ext-enable redis && \
    docker-php-ext-enable xdebug && \
    docker-php-ext-enable imagick && \
    docker-php-ext-enable igbinary && \
    # imagick-3.5.0 will not work
    apk del --purge $PHPIZE_DEPS

@wglambert
Copy link

Yeah PECL extensions are all compiled so we should add a section about temporarily installing $PHPIZE_DEPS

Current status is I'm running into Imagick/imagick#443 (comment)

Error loading shared library libgomp.so.1

FROM php:alpine
RUN apk add $PHPIZE_DEPS imagemagick-dev && \
mkdir -p /usr/src/php/ext/imagick && \
curl -fsSL https://pecl.php.net/get/imagick | tar xvz -C "/usr/src/php/ext/imagick" --strip 1 && \
docker-php-ext-install imagick && \
apk del $PHPIZE_DEPS
$ docker build . -t php:test
Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM php:alpine
 ---> b224257ffa36
Step 2/2 : RUN apk add $PHPIZE_DEPS imagemagick-dev && mkdir -p /usr/src/php/ext/imagick && curl -fsSL https://pecl.php.net/get/imagick | tar xvz -C "/usr/src/php/ext/imagick" --strip 1 && docker-php-ext-install imagick && apk del $PHPIZE_DEPS
 ---> Using cache
 ---> 342eae452ce4
Successfully built 342eae452ce4
Successfully tagged php:test

$ docker run --rm php:test php -i | grep imagick
Warning: PHP Startup: Unable to load dynamic library 'imagick.so' (tried: /usr/local/lib/php/extensions/no-debug-non-zts-20200930/imagick.so (Error loading shared library libgomp.so.1: No such file or directory (needed by /usr/local/lib/php/extensions/no-debug-non-zts-20200930/imagick.so)), /usr/local/lib/php/extensions/no-debug-non-zts-20200930/imagick.so.so (Error loading shared library /usr/local/lib/php/extensions/no-debug-non-zts-20200930/imagick.so.so: No such file or directory)) in Unknown on line 0
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-imagick.ini

@wglambert
Copy link

wglambert commented Jun 28, 2021

😉

RUN apk add libgomp

$ cat Dockerfile
FROM php:alpine
RUN apk add $PHPIZE_DEPS imagemagick-dev && \
mkdir -p /usr/src/php/ext/imagick && \
curl -fsSL https://pecl.php.net/get/imagick | tar xvz -C "/usr/src/php/ext/imagick" --strip 1 && \
pecl install imagick && \
docker-php-ext-enable imagick && \
apk del $PHPIZE_DEPS
RUN apk add libgomp
$ docker build . -t php:test
. . .
(1/1) Purging .docker-php-ext-enable-deps (20210628.172520)
OK: 258 MiB in 74 packages
World updated, but the following packages are not removed due to:
  pkgconf: imagemagick-dev

(1/21) Purging autoconf (2.71-r0)
(2/21) Purging m4 (1.4.18-r2)
(3/21) Purging dpkg (1.20.9-r0)
(4/21) Purging dpkg-dev (1.20.9-r0)
(5/21) Purging perl (5.32.1-r0)
(6/21) Purging file (5.40-r1)
(7/21) Purging g++ (10.3.1_git20210424-r2)
(8/21) Purging gcc (10.3.1_git20210424-r2)
(9/21) Purging binutils (2.35.2-r2)
(10/21) Purging libatomic (10.3.1_git20210424-r2)
(11/21) Purging libgomp (10.3.1_git20210424-r2)
(12/21) Purging libgphobos (10.3.1_git20210424-r2)
(13/21) Purging libc-dev (0.7.2-r3)
(14/21) Purging musl-dev (1.2.2-r3)
(15/21) Purging make (4.3-r0)
(16/21) Purging re2c (2.1.1-r0)
(17/21) Purging libmagic (5.40-r1)
(18/21) Purging mpc1 (1.2.1-r0)
(19/21) Purging mpfr4 (4.1.0-r0)
(20/21) Purging isl22 (0.22-r0)
(21/21) Purging gmp (6.2.1-r0)
Executing busybox-1.33.1-r2.trigger
OK: 27 MiB in 53 packages
Removing intermediate container 39268f246749
 ---> ffb50816a112
Step 3/3 : RUN apk add libgomp
 ---> Running in fa9c301bdddc
(1/1) Installing libgomp (10.3.1_git20210424-r2)
OK: 27 MiB in 54 packages
Removing intermediate container fa9c301bdddc
 ---> 3964e546eb50
Successfully built 3964e546eb50
Successfully tagged php:test

$ docker run --rm php:test php -i | grep imagick
Additional .ini files parsed => /usr/local/etc/php/conf.d/docker-php-ext-imagick.ini,
imagick
imagick module => enabled
imagick module version => 3.5.0
imagick classes => Imagick, ImagickDraw, ImagickPixel, ImagickPixelIterator, ImagickKernel
imagick.allow_zero_dimension_images => 0 => 0
imagick.locale_fix => 0 => 0
imagick.progress_monitor => 0 => 0
imagick.set_single_thread => 1 => 1
imagick.shutdown_sleep_count => 10 => 10
imagick.skip_version_check => 0 => 0

@tianon
Copy link
Member

tianon commented Jun 29, 2021

See also how WordPress handles this:

https://github.com/docker-library/wordpress/blob/35f4b2751ed7ded4c9462a66346952df4a50e2d0/latest/php7.4/fpm-alpine/Dockerfile#L22-L56

(which is a tad verbose but results in the smallest possible installation and without explicitly listing runtime dependencies -- only build-time)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants