Freetype-config not found error when we install gd in php7.2-apache in Docker
Referring to the reply from https://github.com/docker-library/php/issues/865#issuecomment-511163936 firstly you have to patch and fix the php bug (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
then using the following cmd :
RUN docker-php-ext-configure gd --with-freetype-dir --with-jpeg-dir=/usr/include/
I have verified it's working for php7.2-fpm
This issue is extensively clarified in the related GitHub issue, see in particular this comment.
In brief, the whole issue is related to a change in the default Debian version. Rather than applying patches or taking more complex routes, all that is needed is to add reference to stretch
in the FROM line at the beginning of the Dockerfile. In this case, the first line should read:
FROM: php:7.2-apache-stretch
All else should work as expected.