0

I'm trying to install php yaml extension.

My Dockerfile :

FROM php:fpm-alpine


# gd
RUN apk add --update --no-cache \
      freetype-dev \
      libjpeg-turbo-dev \
      libpng-dev \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j"$(getconf _NPROCESSORS_ONLN)" gd


# imagick
RUN apk add --update --no-cache autoconf g++ imagemagick-dev libtool make pcre-dev \
    && pecl install imagick \
    && docker-php-ext-enable imagick \
    && apk del autoconf g++ libtool make pcre-dev


# Yaml
RUN apk add --no-cache \
      yaml-dev
RUN pecl install yaml
# I've trying with yaml-2.0.4 too...
RUN docker-php-ext-enable yaml

# Copy php conf files
COPY php-fpm.conf /usr/local/etc/php-fpm.d/www-user.conf
COPY php.ini /usr/local/etc/php/conf.d/50-setting.ini

Error :

ERROR: Service 'php' failed to build: The command '/bin/sh -c pecl install yaml' returned a non-zero code: 1

Why it's so complicated to install a basic php extension in 2019 ? It's normal that no documentation explain that ?

EDIT: No it's not same as "add yaml extension to php on using official Alpine Docker image". I known how to search and I've found this answer before post my question but this solution doesn't work for me (and also answer is outdated...).

EDIT 2 : I found. So like David Maze said I have to install dependencies with yaml (of course it's not possible to automaticly install them, 2019, great job everyone !). So now I install imagick in same time as yaml :

FROM php:fpm-alpine


# gd
RUN apk add --update --no-cache \
      freetype-dev \
      libjpeg-turbo-dev \
      libpng-dev \
    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
    && docker-php-ext-install -j"$(getconf _NPROCESSORS_ONLN)" gd


# imagick & yaml
RUN apk add --update --no-cache autoconf g++ imagemagick-dev libtool make pcre-dev yaml-dev \
    && pecl install imagick \
    && docker-php-ext-enable imagick \
    && pecl install yaml \
    && docker-php-ext-enable yaml \
    && apk del autoconf g++ libtool make pcre-dev


# Copy php conf files
COPY php-fpm.conf /usr/local/etc/php-fpm.d/www-user.conf
COPY php.ini /usr/local/etc/php/conf.d/50-setting.ini
Chenille33
  • 93
  • 1
  • 1
  • 10
  • Including the actual error message, and not just the "it failed" line, would be helpful. A strong guess is that you're uninstalling the C compiler the line before this installation but the package requires a native extension. – David Maze Oct 25 '19 at 14:10
  • 1
    I'm not sure that 5052545151541254 lines of log helping... – Chenille33 Oct 25 '19 at 14:11
  • check which user the container is run as, because installing pecl exts requires root – Lawrence Cherone Oct 25 '19 at 14:13
  • I use default installation so I guess than team who build this image has correctly make his job and the correct user running... In addition, other extensions are installed correctly... – Chenille33 Oct 25 '19 at 14:14

0 Answers0