installing php-gd dependencies on alpine linux in php5-fpm-alpine docker container

Trying to install GD dependencies on alpine linux in docker.

I'm building php5-fpm-alpine image.

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

I get error:

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]

I've limited experience with alpine distro. and it seems to be not very popular, ergo little information or not at all via google.

The package names in the example from docker hub are for the debian version. You must use the packages from alpine. You can search for alpine packages here: https://pkgs.alpinelinux.org/packages.

The following should work:

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