Warm tip: This article is reproduced from serverfault.com, please click

How to add image magick to my laravel under docker project?

发布于 2020-12-01 12:12:51

Running my laravel app under docker I want to add image magick support with adding libmagickwand-dev lib, but got error:

and I got errors running docker-compose up -d --build :

...
Step 7/9 : RUN  docker-php-ext-install gd pdo pdo_mysql zip gmp bcmath pcntl ldap sysvmsg exif  && a2enmod rewrite
 ---> Using cache
 ---> 57b5ffd40a2f
Step 8/9 : RUN docker-php-ext-install libmagickwand
 ---> Running in 5066ebf866a8
error: /usr/src/php/ext/libmagickwand does not exist

usage: /usr/local/bin/docker-php-ext-install [-jN] [--ini-name file.ini] ext-name [ext-name ...]
   ie: /usr/local/bin/docker-php-ext-install gd mysqli
       /usr/local/bin/docker-php-ext-install pdo pdo_mysql
       /usr/local/bin/docker-php-ext-install -j5 gd mbstring mysqli pdo pdo_mysql shmop

if custom ./configure arguments are necessary, see docker-php-ext-configure

Possible values for ext-name:                                                                                                                                                                                          
bcmath bz2 calendar ctype curl dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap mbstring mysqli oci8 odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zend_test zip                                                                                                                                                                                                     
                                                                                                                                                                                                                       
Some of the above modules are already compiled into PHP; please check                                                                                                                                                  
the output of "php -i" to see which modules are already loaded.                                                                                                                                                        
ERROR: Service 'web' failed to build: The command '/bin/sh -c docker-php-ext-install libmagickwand' returned a non-zero code: 1   

In __DOCKER/web/Dockerfile.yml:

In FROM php:7.3-apache

RUN apt-get update && \
    apt-get install -y \
    python \
    libfreetype6-dev \
    libwebp-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    libzip-dev \
    nano \
    mc \
    git-core \

    libmagickwand-dev \

    curl \
    ...
  RUN npm install cross-env

  RUN npm install -g yarn

  RUN  docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-webp-dir=/usr/include/  --with-jpeg-dir=/usr/include/


  # Install Composer
  RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

  RUN  docker-php-ext-install gd pdo pdo_mysql zip gmp bcmath pcntl ldap sysvmsg exif  \
&& a2enmod rewrite

#  RUN install-php-extensions imagick
  RUN docker-php-ext-install libmagickwand

COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf

I am not sure, but searching in net I found hints that image magick is not supported if docker is installed from php:7.3-apache... Is it so ? How to add image magick to my project ?

Thanks!

Questioner
mstdmstd
Viewed
0
Jonathan privé 2020-12-01 22:15:58

Hello I found that post
If it can help you, the keywords on google : docker php 7.3 with imagick

For advice I also suggest you to take a look on vips to potentially replace imagick if you don't find any solution.