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

Adding php-imagick extension to Alpine Docker container fails #1532

Open
4d4ch4u32 opened this issue Jul 30, 2024 · 3 comments
Open

Adding php-imagick extension to Alpine Docker container fails #1532

4d4ch4u32 opened this issue Jul 30, 2024 · 3 comments

Comments

@4d4ch4u32
Copy link

I try to add the imagick php extension to my Docker container:

FROM php:8.3-fpm-alpine AS base

RUN apk add --update --no-cache --virtual .build-deps $PHPIZE_DEPS imagemagick imagemagick-dev \
    && pecl install imagick \
    && docker-php-ext-enable imagick \
    &&  rm -rf /tmp/pear \
    && apk del .build-deps

The process fails with the following error:

14.37 PHP-Parser-5.0.0/phpstan.neon.dist
14.38 Saved /tmp/pear/temp/imagick/ImagickPixel_arginfo.h
14.38 Parse /tmp/pear/temp/imagick/Imagick.stub.php to generate /tmp/pear/temp/imagick/Imagick_arginfo.h
14.41 In /tmp/pear/temp/imagick/Imagick.stub.php:
14.41 Unterminated preprocessor conditions
14.41 make: *** [Makefile:196: /tmp/pear/temp/imagick/Imagick_arginfo.h] Error 1
14.41 ERROR: `make INSTALL_ROOT="/tmp/pear/temp/pear-build-defaultuserAclDeF/install-imagick-3.7.0" install' failed
------
failed to solve: process "/bin/sh -c apk add --update --no-cache --virtual .build-deps $PHPIZE_DEPS imagemagick imagemagick-dev     && pecl install imagick     && docker-php-ext-enable imagick     &&  rm -rf /tmp/pear     && apk del .build-deps" did not complete successfully: exit code: 1
@tianon
Copy link
Member

tianon commented Jul 30, 2024

@4d4ch4u32
Copy link
Author

Same error

@tianon
Copy link
Member

tianon commented Jul 30, 2024

FROM php:8.3-fpm-alpine

RUN set -eux; \
	apk add --no-cache imagemagick-dev; \
# WARNING: imagick is likely not supported on Alpine: https://github.com/Imagick/imagick/issues/328
# https://pecl.php.net/package/imagick
# https://github.com/Imagick/imagick/commit/5ae2ecf20a1157073bad0170106ad0cf74e01cb6 (causes a lot of build failures, but strangely only intermittent ones 🤔)
# see also https://github.com/Imagick/imagick/pull/641
# this is "pecl install imagick-3.7.0", but by hand so we can apply a small hack / part of the above commit
	curl -fL -o imagick.tgz 'https://pecl.php.net/get/imagick-3.7.0.tgz'; \
	echo '5a364354109029d224bcbb2e82e15b248be9b641227f45e63425c06531792d3e *imagick.tgz' | sha256sum -c -; \
	tar --extract --directory /tmp --file imagick.tgz imagick-3.7.0; \
	grep '^//#endif$' /tmp/imagick-3.7.0/Imagick.stub.php; \
	test "$(grep -c '^//#endif$' /tmp/imagick-3.7.0/Imagick.stub.php)" = '1'; \
	sed -i -e 's!^//#endif$!#endif!' /tmp/imagick-3.7.0/Imagick.stub.php; \
	grep '^//#endif$' /tmp/imagick-3.7.0/Imagick.stub.php && exit 1 || :; \
	docker-php-ext-install /tmp/imagick-3.7.0; \
	rm -rf imagick.tgz /tmp/imagick-3.7.0

RUN php -i | grep imagick
$ docker build --pull .
...
Step 3/3 : RUN php -i | grep imagick
 ---> Running in 531b364f41dc
/usr/local/etc/php/conf.d/docker-php-ext-imagick.ini,
imagick
imagick module => enabled
imagick module version => 3.7.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
Removing intermediate container 531b364f41dc
 ---> 4ab775ff67f2
Successfully built 4ab775ff67f2

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

No branches or pull requests

2 participants