php: Installing gd on buster results in freetype-config not found
Not using cached versions. I’ve tested the install on another device, same output.
Dockerfile:
FROM php:7.3.7-fpm
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/freetype --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd \
&& rm -r /var/lib/apt/lists/*
configure: error: freetype-config not found.
ERROR: Service 'php' failed to build: The command '/bin/sh -c apt update && apt install -y --no-install-recommends libfreetype6-dev libjpeg62-turbo-dev libpng-dev && docker-php-ext-install -j$(nproc) iconv && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && docker-php-ext-install -j$(nproc) gd && rm -r /var/lib/apt/lists/*' returned a non-zero code: 1
The issue is present when using the latest version 7.3.7-fpm (buster) The build succeeds when using 7.3.6-fpm (stretch)
TLDR solution for now Use a tag with stretch instead of buster.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 40
- Comments: 32 (2 by maintainers)
Commits related to this issue
- workaround for https://github.com/docker-library/php/issues/865 — committed to Tiffel/eqdkp by deleted user 5 years ago
- docker: Use php7.2-apache-stretch as a workaround for a Docker PHP bug - This is a workaround for docker-library/php#865 which broke all LibreSignage Docker builds. The workaround will be used for ... — committed to eerotal/LibreSignage by deleted user 5 years ago
- [magento2] Fixes for Magento 2.3.2 - Add support for Magento 2.3.2 - Added a workaround for https://github.com/docker-library/php/issues/865 — committed to DuckThom/docker-images by DuckThom 5 years ago
- Dockerfile: Stretch Base Image https://github.com/docker-library/php/issues/865 — committed to dargmuesli/randomwinpicker by dargmuesli 5 years ago
- Dockerfile: Stretch Base Image https://github.com/docker-library/php/issues/865 — committed to dargmuesli/jonas-thelemann by dargmuesli 5 years ago
- Pin Debian variants to stretch for now The plan is to switch to buster once https://github.com/docker-library/php/issues/865 is resolved in a clean way (either in the PHP image or in PHP itself). — committed to docker-library/drupal by tianon 5 years ago
- Add temporary "freetype-config" workaround for PHP 7.3, 7.2, and 7.1 on buster See: - https://github.com/docker-library/php/issues/865 - https://bugs.php.net/bug.php?id=76324 - https://github.com/ph... — committed to infosiftr/php by tianon 5 years ago
- Use debian stretch for php images to workaround docker-library/php#865 — committed to inetum-orleans/generator-docker-devbox by Toilal 5 years ago
- ignore: docker build failed. docker-library/php#865 — committed to wifidog/wifidog-auth-laravel by sinkcup 5 years ago
- Add temporary "freetype-config" workaround for PHP 7.3, 7.2, and 7.1 on buster See: - https://github.com/docker-library/php/issues/865 - https://bugs.php.net/bug.php?id=76324 - https://github.com/ph... — committed to ReactDevs007/dockerlib by ReactDevs007 5 years ago
- Add temporary "freetype-config" workaround for PHP 7.3, 7.2, and 7.1 on buster See: - https://github.com/docker-library/php/issues/865 - https://bugs.php.net/bug.php?id=76324 - https://github.com/ph... — committed to ene519/docker-library-php by ene519 5 years ago
- Add temporary "freetype-config" workaround for PHP 7.3, 7.2, and 7.1 on buster See: - https://github.com/docker-library/php/issues/865 - https://bugs.php.net/bug.php?id=76324 - https://github.com/ph... — committed to VenusPR/PHP_Project by VenusPR 5 years ago
- Add temporary "freetype-config" workaround for PHP 7.3, 7.2, and 7.1 on buster See: - https://github.com/docker-library/php/issues/865 - https://bugs.php.net/bug.php?id=76324 - https://github.com/ph... — committed to MuzanEDM/docker-php by MuzanEDM 5 years ago
- Fix building php56-gd with current freetype2 Clean fix for building php56-gd with current freetype2. Tested on FreeBSD 12.4 with freebsd-ports tree branch 2023Q4 with freetype2-2.13.1. See also pre... — committed to mariancerny/freebsd-ports-php56 by mariancerny 2 months ago
- Fix building php56-gd with current freetype2 Clean fix for building php56-gd with current freetype2. Tested on FreeBSD 12.4 with freebsd-ports tree branch 2023Q4 with freetype2-2.13.1. See also pre... — committed to mariancerny/freebsd-ports-php56 by mariancerny 2 months ago
I believe most people here don’t really understand what’s happening / going on.
The latest released docker images with the default tags (e.g.
php:7.3-fpm
) are now based on Debian Buster instead of Debian Stretch before.Debian Buster uses a more up-to-date version of the
libfreetype6-dev
(libfreetype6
) package (version2.9.1-3
instead of2.6.3-3.2
before). But Version 2.9.1-3 isn’t shipped withfreetype-config
anymore, as it was removed and the package maintainers recommend to replace calls tofreetype-config
by calls topkg-config
.So as I have already commented a few times before here: Switch to the tags suffixing with
-stretch
. E.g. instead of usingphp:7.3-fpm
you usephp:7.3-fpm-stretch
. Or instead ofphp:7.2-apache
you usephp:7.2-apache-stretch
. That’s it.For people looking here for a QUICK FIX
Set the version of used image to stretch.
If you use for example PHP-FPM 7.3 then in your Dockerfile replace this:
with this:
Works for me and the error is gone.
No, not really a good idea. You’ll end up stuck with 7.2.19 or 7.3.6 and won’t receive any security fixes, etc. anymore.
Better use this:
or:
I’m curious on why the switch to buster was done “silently” by that I mean why isn’t strech still the default and
-buster
an option? it just confused me as php at least since 7.* times is all about bc compatibility and this somewhat goes against that philosophy.Kind of OT, but is it really such a good idea to switch OS version within a minor release? Didn’t expect a switch from Stretch to Buster from 7.3.6 to 7.3.7. Pretty unexpected.
This shouldn’t be an issue with PHP 7.4 because of the migration to
pkg-config
. https://github.com/php/php-src/blob/PHP-7.4/UPGRADING#L606This has been a problem for a wee while for linux distros like Arch that have newer versions running. https://bugs.php.net/bug.php?id=76324
The patch here adds dection via pkg-config https://git.archlinux.org/svntogit/packages.git/tree/trunk/freetype.patch?h=packages/php (
pkg-config freetype2 --cflags
andpkg-config freetype2 --libs
as @StefanPrintezis notes)Extracting the PHP source early in your
Dockerfile
and patching it is one way to work around this.I added
patch
andpkg-config
in the example for clarity, I didn’t check to see if they’re included in the buster image by default.The issue also exist in
php:7.2-apache
image 😦This is a known issue in PHP upstream: https://bugs.php.net/bug.php?id=76324
For PHP 7.4+ (still a pre-release), the solution is to simply use
--with-freetype
and it will usepkg-config
as appropriate to findfreetype
.For older PHP releases, the solution is more complicated and likely involves some variation of https://git.archlinux.org/svntogit/packages.git/tree/php/trunk/freetype.patch, which IMO should really be applied as a backport upstream for handling
pkg-config
as a fallback in conjunction withfreetype-config
. We might need to consider applying something like that to our builds, but that’s a solution of last resort – we provide a stock PHP upstream experience as much as possible, and applying patches that ought to be applied upstream is something we try to strongly avoid.For many users, the solution is likely going to be switching to explicitly use
-stretch
as described above. To be clear, this is exactly what those Debian release named aliases were added for, and why thestretch
variants are not deprecated/removed yet.Probably. The changelog for libfreetype6-dev states:
I guess that
docker-php-ext-configure gd
didn’t anticipate this change…For those still using the freetype.patch here is a working URL. https://git.archlinux.org/svntogit/packages.git/plain/trunk/freetype.patch?h=packages/php&id=a8e8e87f405e0631b2a4552656413735ebf9457c
FROM php:fpm
also have this probrem, change to
FROM php:fpm-stretch
It Works for me and the error is gone.
same issue with
php:7.1-fpm
, solved with changing version tophp:7.1-fpm-stretch
(as @jvanoosterom did)for those using 7.2-fpm image using 7.2-fpm-stretch not worked but instead 7.2.20-fpm-stretch worked
This might be related switching to buster from stretch?
# I just hit this bug while installing php-7.3.12 onto debian 10.1
# Freetype 2.10.1 (and maybe earlier) offers a configure option to compile its much-missed freetype-config:
cd /usr/local/src/freetype-2.10.1 ./configure --prefix=/usr/local/freetype-2.10.1 --enable-freetype-config
# Then tell php configure about it
cd /usr/local/src/php-7.3.12 ./configure <lots of other options> --with-freetype-dir=/usr/local/freetype-2.10.1
For now I am using the following workaround in my custom image as I’m running Magento 2.3.2 and that requires a libsodium version that’s not shipped in stretch.
same issue with php:7.1-apache
edit: solved with changing to version: php:7.1-apache-stretch
Same issue with
wordpress:5.2.2-apache
(that’s building FROMphp:7.3-apache
)The same issue was closed a year ago in #608 for not being reproducable.
Relevant issue in Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=870618
Same here,
php:7.1-apache-stretch
FTW!Use a base image based on Debian Stretch instead of Buster: