0

I am trying to get ImageMagick and it's PHP extension working on a docker image

Docker Image:

FROM laravelphp/vapor:php81

RUN apk add imagemagick imagemagick-dev
RUN pecl install imagick
RUN docker-php-ext-enable imagick

COPY . /var/task

Running these commands gives the following error

  Step 1/5 : FROM laravelphp/vapor:php81                                                           
  php81: Pulling from laravelphp/vapor                                                             
  Digest: sha256:571d520c322df43e1a48ac28e1ff3ad88bf53a35d23837affd35f72fcdb35abd                  
  Status: Image is up to date for laravelphp/vapor:php81                                           
   ---> 46ebf272fe20                                                                               
  Step 2/5 : RUN apk add imagemagick imagemagick-dev                                               
   ---> Using cache                                                                                
   ---> 375e8ed62ce3                                                                               
  Step 3/5 : RUN pecl install imagick                                                              
   ---> Running in bc31590649b8 
                                                                   
  No releases available for package "pecl.php.net/imagick"                                         
  install failed   

What can I change to make pecl install imagick ?

imike
  • 5,515
  • 2
  • 37
  • 44
sietse85
  • 1,488
  • 1
  • 10
  • 26
  • I did something with `pecl` and **ImageMagick** ages ago and wrote quite a few notes. Something here might give a hint https://stackoverflow.com/a/50529784/2836621 – Mark Setchell Sep 14 '22 at 06:29
  • 1
    @MarkSetchell thanks but that does not solve it for me. – sietse85 Sep 14 '22 at 08:32

2 Answers2

3

In my case got it working with the following Dockerfile:

FROM laravelphp/vapor:php81

RUN apk add imagemagick imagemagick-dev php81-pecl-imagick \
&& pecl install imagick \
&& docker-php-ext-enable imagick

COPY . /var/task
sietse85
  • 1,488
  • 1
  • 10
  • 26
2

I can share with you my working dockerfile:

FROM laravelphp/vapor:php81

RUN apk add --no-cache ${PHPIZE_DEPS} imagemagick

RUN pecl install -o -f imagick\
    &&  docker-php-ext-enable imagick

RUN apk del --no-cache ${PHPIZE_DEPS}

RUN php -i

COPY . /var/task
Valkoff
  • 46
  • 5