我正在尝试从 Dockerfile 安装图像 php:7.2-apache,
但我在 gd 配置上有问题。
我已经从页面 https://github.com/docker/toolbox/releases/tag/v18.09.3 安装了最新版本的 docker toolbox 18.09.3因为我有 Windows Home 10
Dockerfile 的内容如下
FROM php:7.2-apache
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
我有这个错误配置:错误:找不到freetype-config。在图像构建过程中
checking for the location of libwebp... no
checking for the location of libjpeg... /usr/include/
checking for the location of libpng... no
checking for the location of libz... no
checking for the location of libXpm... no
checking for FreeType 2... /usr/include/
checking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-webp-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yes
checking for png_write_image in -lpng... yes
If configure fails try --with-xpm-dir=<DIR>
configure: error: freetype-config not found.
Service 'apache_php' failed to build: The command '/bin/sh -c apt-get update && apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install -j$(nproc) gd' returned a non-zero code: 1
任何解决方案?
请您参考如下方法:
引用来自https://github.com/docker-library/php/issues/865#issuecomment-511163936的回复
首先,您必须修补并修复 php 错误 ( https://bugs.php.net/bug.php?id=76324 )
RUN apt-get update && apt-get install -y pkg-config patch
ADD https://git.archlinux.org/svntogit/packages.git/plain/trunk/freetype.patch?h=packages/php /tmp/freetype.patch
RUN docker-php-source extract; \
cd /usr/src/php; \
patch -p1 -i /tmp/freetype.patch; \
rm /tmp/freetype.patch
然后使用以下 cmd :
RUN docker-php-ext-configure gd --with-freetype-dir --with-jpeg-dir=/usr/include/
我已经验证它适用于 php7.2-fpm