Problem: Call to undefined function imagettfbbox
. Output of function_exists('imagettfbbox')
is false
.
I’ve seen so many Dockerfiles now, and it seems not so difficult to enable Freetype with gd. However, although my Dockerfile builds without errors, Freetype is not enabled when I look at phpinfo…
What am I missing?
GD Support enabled
GD Version bundled (2.1.0 compatible)
GIF Read Support enabled
GIF Create Support enabled
PNG Support enabled
libPNG Version 1.6.37
WBMP Support enabled
XBM Support enabled
BMP Support enabled
TGA Read Support enabled
Here’s my Dockerfile
FROM php:8.1.5-fpm-alpine3.15
ENV PHP_OPCACHE_VALIDATE_TIMESTAMPS="0"
PHP_OPCACHE_MAX_ACCELERATED_FILES="20000"
PHP_OPCACHE_MEMORY_CONSUMPTION="256"
PHP_OPCACHE_MAX_WASTED_PERCENTAGE="10"
RUN apk add bash curl zip libzip-dev libxpm libxpm-dev libpng libpng-dev libwebp libwebp-dev libjpeg-turbo libjpeg-turbo-dev freetype freetype-dev imagemagick imagemagick-dev && rm /var/cache/apk/*
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
RUN docker-php-ext-install pdo_mysql
RUN apk add $PHPIZE_DEPS
RUN pecl install redis
RUN docker-php-ext-configure zip
RUN docker-php-ext-configure gd --enable-gd --with-webp --with-jpeg --with-xpm --with-freetype
RUN docker-php-ext-install zip opcache
RUN docker-php-ext-install gd
RUN docker-php-ext-enable redis
RUN apk del --purge autoconf g++ make
WORKDIR /var/www
COPY ./dockerfiles/php/php.ini /usr/local/etc/php/php.ini
COPY ./dockerfiles/php/php-fpm-pool.conf /usr/local/etc/php-fpm.d
COPY ./dockerfiles/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
COPY ./app/ /var/www
RUN PATH=$PATH:/var/www/bin:bin
RUN composer install
CMD ["php-fpm", "-F"]
And the referenced configs:
# php.ini
realpath_cache_size=1M
realpath_cache_ttl=300
upload_max_filesize=16M
date.timezone="Europe/Belgrade"
session.save_handler=redis
session.save_path="localhost:6379"
# php-fpm-pool.conf
[www]
user = www-data
group = www-data
listen = 0.0.0.0:9000
listen.backlog = 1023
pm = dynamic
pm.max_children = 8
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.status_path = /php-fpm-status
ping.path = /php-fpm-ping
request_terminate_timeout = 5m
chdir = /
catch_workers_output = yes
clear_env = no
# opcache.ini
[opcache]
opcache.enable=1
opcache.revalidate_freq=0
#opcache.validate_timestamps=${PHP_OPCACHE_VALIDATE_TIMESTAMPS}
opcache.max_accelerated_files=${PHP_OPCACHE_MAX_ACCELERATED_FILES}
opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}
opcache.max_wasted_percentage=${PHP_OPCACHE_MAX_WASTED_PERCENTAGE}
opcache.interned_strings_buffer=16
opcache.fast_shutdown=1
2
Answers
Maybe this could solve it:
I was able to build with the Freetype support using this Dockerfile
Since PHP 7.4 …-dir options (like –with-freetype-dir, –with-jpeg-dir, etc.) were removed, so
--prefix=/usr
should be used.gd_info() output