[英]docker php:7.1-fpm-alpine fails to build GD
Trying to build from the official php:7.1-fpm-alpine
image, using the following excerpt in my Dockerfile:尝试从官方
php:7.1-fpm-alpine
镜像构建,使用我的 Dockerfile 中的以下摘录:
FROM php:7.1-fpm-alpine
RUN set -ex \
apk add --no-cache --virtual .build-deps \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
\
&& docker-php-ext-configure gd \
--with-freetype-dir=/usr \
--with-png-dir=/usr \
--with-jpeg-dir=/usr \
&& docker-php-ext-install gd \
&& apk del .build-deps
When attempting to build this with docker build
, GD fails during ./configure
with the following error:尝试使用
docker build
,GD 在./configure
期间失败并出现以下错误:
configure: error: jpeglib.h not found
I can confirm that jpeglib.h
exists and is exactly where I think it should be (indeed, exactly where it is in Debian variants):我可以确认
jpeglib.h
存在并且正是我认为它应该在的地方(实际上,它在 Debian 变体中的确切位置):
$ docker run -it --rm php:7.1-fpm-alpine /bin/sh
>$ apk add --no-cache libjpeg-turbo-dev \
&& find /usr -type f -name 'jpeglib.h'
...
/usr/include/jpeglib.h
But if I take exactly the same command used in the dockerfile and run it interactively inside the container, it builds flawlessly.但是如果我使用 dockerfile 中使用的完全相同的命令并在容器内以交互方式运行它,它就会完美地构建。 No errors.
没有错误。
Is this a bug, or am I missing something?这是一个错误,还是我错过了什么?
The problem was a blindingly simple syntax error;问题是一个非常简单的语法错误; the
apk
call following the set
command needs to be preceded by &&
, otherwise the interpreter is treating the entire apk
call as a set of arguments to set
.在
apk
以下的呼叫set
命令需要在前面加&&
,否则解释器处理的整个apk
呼叫作为一组参数来set
。 In that case, the packages aren't added, therefore jpeglib.h
didn't exist.在这种情况下,不会添加包,因此
jpeglib.h
不存在。
When I typed the command into the shell, I used the correct syntax, so it passed without error.当我在 shell 中输入命令时,我使用了正确的语法,所以它没有错误地通过。
yes, you should write like this是的,你应该这样写
RUN set -ex \
&& apk add --no-cache --virtual .build-deps \
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.