在php5-fpm-alpine docker容器中安装php-gd依赖于alpine linux

试图在docker中的alpine linux上安装GD依赖项.

我正在构建php5-fpm-alpine图像.

FROM php:5-fpm-alpine
RUN docker-php-ext-install mysqli
RUN apk upgrade --update && apk add \
        libfreetype6-dev \
        libjpeg62-turbo-dev \
        libmcrypt-dev \
        libpng12-dev \
    && docker-php-ext-install -j$(nproc) mcrypt \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j$(nproc) gd

我收到错误:

ERROR: unsatisfiable constraints:
  libfreetype6-dev (missing):
    required by: world[libfreetype6-dev]
  libjpeg62-turbo-dev (missing):
    required by: world[libjpeg62-turbo-dev]
  libpng12-dev (missing):
    required by: world[libpng12-dev]

我对高山发行的经验有限.它似乎不是很受欢迎,ergo信息很少或根本没有通过谷歌.

最佳答案
docker hub示例中的软件包名称适用于debian版本.你必须使用alpine的包裹.您可以在这里搜索高山包裹:https://pkgs.alpinelinux.org/packages.

以下应该有效:

FROM php:5-fpm-alpine
RUN docker-php-ext-install mysqli
RUN apk upgrade --update && apk add \
  coreutils \
  freetype-dev \
  libjpeg-turbo-dev \
  libltdl \
  libmcrypt-dev \
  libpng-dev \
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd

转载注明原文:在php5-fpm-alpine docker容器中安装php-gd依赖于alpine linux - 代码日志