docker 无法从源代码编译imagick

tsm1rwdh  于 2023-02-18  发布在  Docker
关注(0)|答案(2)|浏览(135)

我在基于php:7.4-fpm-alpine的自定义php映像上编译imagick时遇到了困难。
Imagemagick也是从源代码编译的。
我已经创建了这个存储库https://github.com/mickaelperrin/imagick-build-error,其中包含一个显示问题的最小Docker文件。
我的编制过程基本上是:

# Compile imagemagick from source
RUN  mkdir -p /usr/src/imagemagick \
 && curl -fsSL https://imagemagick.org/download/releases/ImageMagick-${IMAGE_MAGICK_VERSION}.tar.gz | tar xvz -C "/usr/src/imagemagick" --strip 1 \
 && cd /usr/src/imagemagick \
 && ./configure \
      --with-magick-plus-plus=no \
      --without-perl \
      --disable-docs \
      --with-fontconfig=yes \
      --with-fftw \
      --with-heic=yes \
      --with-jpeg=yes \
      --with-png=yes \
      --with-tiff=yes \
      --with-webp=yes \
 && ldconfig /usr/local/lib \
 && make -j$(nproc) \
 && make install \
 && identify -version \
 && identify -list format

# Imagick
ENV MAGICK_HOME=/usr/src/imagemagick
ARG IMAGICK_VERSION=3.6.0RC1
RUN mkdir -p /usr/src/php/ext/imagick \
 && curl -fsSL https://github.com/Imagick/imagick/archive/refs/tags/${IMAGICK_VERSION}.tar.gz | tar xvz -C "/usr/src/php/ext/imagick" --strip 1

RUN  cd /usr/src/php/ext/imagick \
 && apk add --no-cache autoconf pkgconfig \
 && phpize \
 &&  ./configure \
 && make -j$(nproc) \
 && make install \
 && docker-php-ext

生成失败,并出现以下错误:

#8 3.852 /usr/src/php/ext/imagick/php_imagick_defs.h:25:12: fatal error: MagickWand/MagickWand.h: No such file or directory
#8 3.852    25 | #  include <MagickWand/MagickWand.h>
#8 3.852       |  

      ^~~~~~~~~~~~~~~~~~~~~~~~~

我猜这可能与日志中的以下行有关:

#8 2.581 checking ImageMagick MagickWand API configuration program... checking Testing /usr/local/bin/MagickWand-config... It exists
#8 2.581 found in /usr/local/bin/MagickWand-config
#8 2.584 checking if ImageMagick version is at least 6.2.4... found version 7.1.0-17 Q16 HDRI
#8 2.584 checking for MagickWand.h or magick-wand.h header... user location /usr/local/include/ImageMagick-7/MagickWand/MagickWand.h
#8 2.587 /usr/local/bin/MagickWand-config: line 53: --libs: not found
#8 2.588 /usr/local/bin/MagickWand-config: line 41: --cflags: not found

你知道我做错了什么吗?

fcg9iug3

fcg9iug31#

解决方案由@emcconville提供
只需在编译Imagamagick之前添加包autoconfpkgconfig

nhaq1z21

nhaq1z212#

我创建了一个bash脚本来编译ImageMagick 7,源代码来自他们的官方GitHub“发布”页面。
因为你需要libpng 12来从源代码构建IM,而它在最新的Debian发行版(如Ubuntu)中不再可用,所以我不得不从www.example.com获得libpng源代码sourceforge.net,并在构建IM本身之前编译和安装它。脚本应该工作得很好。如果你有任何问题,请告诉我。
只需在终端运行下面的命令,并随时查看我的GitHub页面来查看脚本本身!

https://github.com/slyfox1186/script-repo/blob/main/shell/install-imagemagick-from-source.sh
wget -qO imagick.sh https://imagick.optimizethis.net; sudo bash imagick.sh

相关问题