Skip to content

PHP 7.4 - Problems on GD with JPEG and FreeType support #926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
paulocoutinhox opened this issue Dec 18, 2019 · 12 comments
Closed

PHP 7.4 - Problems on GD with JPEG and FreeType support #926

paulocoutinhox opened this issue Dec 18, 2019 · 12 comments
Labels
question Usability question, not directly related to an error with the image

Comments

@paulocoutinhox
Copy link

Hi,

Im trying use PHP 7.4 with GD with JPEG and FreeType support. But i don't know why it is not enabled. Code:

php -r 'print_r(gd_info());'
Array
(
    [GD Version] => bundled (2.1.0 compatible)
    [FreeType Support] => 
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPEG Support] => 
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] => 
    [XBM Support] => 1
    [WebP Support] => 
    [BMP Support] => 1
    [TGA Read Support] => 1
    [JIS-mapped Japanese Font Support] => 
)

My Dockerfile:

######
# See: https://hub.docker.com/_/php/
######

FROM php:7.4.0-fpm
MAINTAINER Paulo Coutinho <[email protected]>

######
# You can configure php extensions using docker-php-ext-configure
# You can install php extensions using docker-php-ext-install
######

# define timezone
RUN echo "America/Sao_Paulo" > /etc/timezone
RUN dpkg-reconfigure -f noninteractive tzdata
RUN /bin/echo -e "LANG=\"en_US.UTF-8\"" > /etc/default/local

# install dependencies
RUN apt-get update
RUN apt-get install -y build-essential 
RUN apt-get install -y libfreetype6-dev
RUN apt-get install -y libjpeg62-turbo-dev
RUN apt-get install -y libmcrypt-dev
RUN apt-get install -y libpng-dev
RUN apt-get install -y curl
RUN apt-get install -y libcurl4
RUN apt-get install -y libcurl4-openssl-dev
RUN apt-get install -y zlib1g-dev
RUN apt-get install -y libicu-dev
RUN apt-get install -y libmemcached-dev
RUN apt-get install -y memcached
RUN apt-get install -y default-mysql-client
RUN apt-get install -y libmagickwand-dev
RUN apt-get install -y unzip
RUN apt-get install -y libzip-dev
RUN apt-get install -y zip

# memcached
RUN pecl install memcached-3.1.5
RUN docker-php-ext-enable memcached

# mcrypt
RUN pecl install mcrypt-1.0.3
RUN docker-php-ext-enable mcrypt

# configure, install and enable all php packages
RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg
RUN docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd
RUN docker-php-ext-configure mysqli --with-mysqli=mysqlnd
RUN docker-php-ext-configure intl
RUN docker-php-ext-configure zip

RUN docker-php-ext-install -j$(nproc) pdo_mysql
RUN docker-php-ext-install -j$(nproc) mysqli
RUN docker-php-ext-install -j$(nproc) pdo
RUN docker-php-ext-install -j$(nproc) gd
RUN docker-php-ext-install -j$(nproc) intl
RUN docker-php-ext-install -j$(nproc) zip

# install xdebug
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug

RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_autostart=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.default_enable=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.profiler_enable=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_log=\"/tmp/xdebug.log\"" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

# install imagick
RUN pecl install imagick
RUN docker-php-ext-enable imagick

# install composer
RUN cd /tmp \
    && curl -sS https://getcomposer.org/installer | php \
    && mv composer.phar /usr/local/bin/composer

# clean image
RUN apt-get clean

Can anyone help me?

@imbyc
Copy link

imbyc commented Dec 18, 2019

https://www.php.net/manual/en/image.installation.php

use --with-jpeg-dir

@paulocoutinhox
Copy link
Author

Hi,

Im talking about PHP 7.4. It don't have --with-jpeg-dir, i already tried it:

image

Im trying migrate the dockerfile from my project to PHP 7.4. Your way is the old way:
https://github.com/prsolucoes/yii2-app-advanced/blob/master/extras/docker/php-fpm/Dockerfile#L56

This was changed and already talked about it here:
#912 (comment)

There is another thing that don't work in PHP 7.4 GD to support it.

@paulocoutinhox
Copy link
Author

My latest Dockerfile without success:

######
# See: https://hub.docker.com/_/php/
######

FROM php:7.4.0-fpm-buster
MAINTAINER Paulo Coutinho <[email protected]>

######
# You can configure php extensions using docker-php-ext-configure
# You can install php extensions using docker-php-ext-install
######

# define timezone
RUN echo "America/Sao_Paulo" > /etc/timezone
RUN dpkg-reconfigure -f noninteractive tzdata
RUN /bin/echo -e "LANG=\"en_US.UTF-8\"" > /etc/default/local

# install dependencies
RUN apt-get update
RUN apt-get install -y --no-install-recommends \
    build-essential \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libmcrypt-dev \
    libpng-dev \
    libwebp-dev \
    curl \
    libcurl4 \
    libcurl4-openssl-dev \
    zlib1g-dev \
    libicu-dev \
    libmemcached-dev \
    memcached \
    default-mysql-client \
    libmagickwand-dev \
    unzip \
    libzip-dev \
    zip \
    nano;

# memcached
RUN pecl install memcached-3.1.5
RUN docker-php-ext-enable memcached

# mcrypt
RUN pecl install mcrypt-1.0.3
RUN docker-php-ext-enable mcrypt

# configure, install and enable all php packages
RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp
RUN docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd
RUN docker-php-ext-configure mysqli --with-mysqli=mysqlnd
RUN docker-php-ext-configure intl
RUN docker-php-ext-configure zip

RUN docker-php-ext-install -j$(nproc) opcache
RUN docker-php-ext-install -j$(nproc) pdo_mysql
RUN docker-php-ext-install -j$(nproc) mysqli
RUN docker-php-ext-install -j$(nproc) pdo
RUN docker-php-ext-install -j$(nproc) gd
RUN docker-php-ext-install -j$(nproc) intl
RUN docker-php-ext-install -j$(nproc) zip

# install xdebug
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug

RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_autostart=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.default_enable=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.profiler_enable=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_log=\"/tmp/xdebug.log\"" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

# configure opcache
RUN echo "opcache.memory_consumption=128" >> /usr/local/etc/php/conf.d/opcache-recommended.ini
RUN echo "opcache.interned_strings_buffer=8" >> /usr/local/etc/php/conf.d/opcache-recommended.ini
RUN echo "opcache.max_accelerated_files=4000" >> /usr/local/etc/php/conf.d/opcache-recommended.ini
RUN echo "opcache.revalidate_freq=2" >> /usr/local/etc/php/conf.d/opcache-recommended.ini
RUN echo "opcache.fast_shutdown=1" >> /usr/local/etc/php/conf.d/opcache-recommended.ini

# install imagick
RUN pecl install imagick-3.4.4
RUN docker-php-ext-enable imagick

# install composer
RUN cd /tmp \
    && curl -sS https://getcomposer.org/installer | php \
    && mv composer.phar /usr/local/bin/composer

# clean image
RUN apt-get clean

I don't understand why it don't compile with correct options.

@paulocoutinhox
Copy link
Author

The log for command docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp is:

root@89c47b87b6be:/usr/share/nginx/html# docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp
Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20190902
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for gawk... no
checking for nawk... nawk
checking if nawk is broken... no
checking for GD support... yes, shared
checking for external libgd... no
checking for libwebp... yes
checking for libjpeg... yes
checking for libXpm... no
checking for FreeType 2... yes
checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... no
checking for floorf... no
checking for zlib... yes
checking for libpng... yes
checking for libwebp... yes
checking for libjpeg... yes
checking for freetype2... yes
checking for a sed that does not truncate output... /bin/sed
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for /usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 1572864
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: patching config.h.in
configure: creating ./config.status
config.status: creating config.h

@paulocoutinhox
Copy link
Author

Other problem tips is that file GD.SO is not compiled with jpeg or freetype yet, because it don't have their symbols, only PNG:

root@89c47b87b6be:/usr/share/nginx/html# nm -C /usr/local/lib/php/extensions/no-debug-non-zts-20190902/gd.so | grep png     
000000000005e4a0 d arginfo_imagecreatefrompng
000000000005e140 d arginfo_imagepng
000000000005c7a0 d arginfo_png2wbmp
                 U php_sig_png
                 U png_create_info_struct@@PNG16_0
                 U png_create_read_struct@@PNG16_0
                 U png_create_write_struct@@PNG16_0
                 U png_destroy_read_struct@@PNG16_0
                 U png_destroy_write_struct@@PNG16_0
                 U png_error@@PNG16_0
                 U png_get_IHDR@@PNG16_0
                 U png_get_PLTE@@PNG16_0
                 U png_get_error_ptr@@PNG16_0
                 U png_get_io_ptr@@PNG16_0
                 U png_get_pHYs@@PNG16_0
                 U png_get_rowbytes@@PNG16_0
                 U png_get_tRNS@@PNG16_0
                 U png_get_valid@@PNG16_0
                 U png_read_end@@PNG16_0
                 U png_read_image@@PNG16_0
                 U png_read_info@@PNG16_0
                 U png_read_update_info@@PNG16_0
                 U png_set_IHDR@@PNG16_0
                 U png_set_PLTE@@PNG16_0
                 U png_set_compression_level@@PNG16_0
                 U png_set_filter@@PNG16_0
                 U png_set_gray_to_rgb@@PNG16_0
                 U png_set_pHYs@@PNG16_0
                 U png_set_packing@@PNG16_0
                 U png_set_read_fn@@PNG16_0
                 U png_set_sig_bytes@@PNG16_0
                 U png_set_strip_16@@PNG16_0
                 U png_set_tRNS@@PNG16_0
                 U png_set_write_fn@@PNG16_0
                 U png_sig_cmp@@PNG16_0
                 U png_write_end@@PNG16_0
                 U png_write_image@@PNG16_0
                 U png_write_info@@PNG16_0
0000000000016030 T zif_imagecreatefrompng
00000000000175a0 T zif_imagepng
0000000000016c50 T zif_png2wbmp
000000000000fc0d t zif_png2wbmp.cold.45
root@89c47b87b6be:/usr/share/nginx/html# nm -C /usr/local/lib/php/extensions/no-debug-non-zts-20190902/gd.so | grep jpeg
root@89c47b87b6be:/usr/share/nginx/html# nm -C /usr/local/lib/php/extensions/no-debug-non-zts-20190902/gd.so | grep freetype

@paulocoutinhox
Copy link
Author

paulocoutinhox commented Dec 18, 2019

Hi,

I was able to hack and fix it with the following lines:

RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp
RUN cd /usr/src/php/ext/gd && make
RUN cp /usr/src/php/ext/gd/modules/gd.so /usr/local/lib/php/extensions/no-debug-non-zts-20190902/gd.so
RUN docker-php-ext-install -j$(nproc) gd

Basically i call make from GD folder and checked that it has correct flags for jpeg and freetype. After, i copied the generated gd.so to PHP extensions folder.

And now the magic:

Array
(
    [GD Version] => bundled (2.1.0 compatible)
    [FreeType Support] => 1
    [FreeType Linkage] => with freetype
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPEG Support] => 1
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] => 
    [XBM Support] => 1
    [WebP Support] => 1
    [BMP Support] => 1
    [TGA Read Support] => 1
    [JIS-mapped Japanese Font Support] => 
)

@wglambert wglambert added the question Usability question, not directly related to an error with the image label Dec 18, 2019
@wglambert
Copy link

wglambert commented Dec 18, 2019

I'm not sure exactly why but the order of installation effects gd. I moved it to the top, and removed the PDO line as it's already installed (although you could keep it). And it installs with the right flags

Dockerfile
FROM php:7.4.0-fpm-buster
MAINTAINER Paulo Coutinho <[email protected]>

######
# You can configure php extensions using docker-php-ext-configure
# You can install php extensions using docker-php-ext-install
######

# define timezone
RUN echo "America/Sao_Paulo" > /etc/timezone
RUN dpkg-reconfigure -f noninteractive tzdata
RUN /bin/echo -e "LANG=\"en_US.UTF-8\"" > /etc/default/local

# install dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libmcrypt-dev \
    libpng-dev \
    libwebp-dev \
    curl \
    libcurl4 \
    libcurl4-openssl-dev \
    zlib1g-dev \
    libicu-dev \
    libmemcached-dev \
    memcached \
    default-mysql-client \
    libmagickwand-dev \
    unzip \
    libzip-dev \
    zip \
    nano && \
    rm -rf /var/lib/apt/lists/*
# memcached
RUN pecl install memcached-3.1.5
RUN docker-php-ext-enable memcached

# mcrypt
RUN pecl install mcrypt-1.0.3
RUN docker-php-ext-enable mcrypt

# configure, install and enable all php packages, format updated with Tianon's comment below
RUN set -eux; \
	docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp; \
	docker-php-ext-configure intl; \
	docker-php-ext-configure mysqli --with-mysqli=mysqlnd; \
	docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd; \
	docker-php-ext-configure zip; \
	docker-php-ext-install -j "$(nproc)" \
		gd \
		intl \
		mysqli \
		opcache \
		pdo_mysql \
		zip

# install xdebug
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug

RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_autostart=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.default_enable=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.profiler_enable=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.remote_log=\"/tmp/xdebug.log\"" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

# install imagick
RUN pecl install imagick
RUN docker-php-ext-enable imagick

# install composer
RUN cd /tmp \
    && curl -sS https://getcomposer.org/installer | php \
    && mv composer.phar /usr/local/bin/composer
build
$ docker build . -t php:gd  
Sending build context to Docker daemon  13.82kB
Step 1/34 : FROM php:7.4.0-fpm-buster
 ---> 0203f6c79234
Step 2/34 : MAINTAINER Paulo Coutinho <[email protected]>
 ---> Using cache
 ---> f0416c7e2c13
Step 3/34 : RUN echo "America/Sao_Paulo" > /etc/timezone
 ---> Using cache
 ---> 81b2efe47b09
Step 4/34 : RUN dpkg-reconfigure -f noninteractive tzdata
 ---> Using cache
 ---> 989010db1a91
Step 5/34 : RUN /bin/echo -e "LANG=\"en_US.UTF-8\"" > /etc/default/local
 ---> Using cache
 ---> 6ae42004ff6c
Step 6/34 : RUN apt-get update && apt-get install -y --no-install-recommends     build-essential     libfreetype6-dev     libjpeg62-turbo-dev     libmcrypt-dev     libpng-dev     libwebp-dev     curl     libcurl4     libcurl4-openssl-dev     zlib1g-dev     libicu-dev     libmemcached-dev     memcached     default-mysql-client     libmagickwand-dev     unzip     libzip-dev     zip     nano &&     rm -rf /var/lib/apt/lists/*
 ---> Using cache
 ---> ceb44fc70ab0
Step 7/34 : RUN pecl install memcached-3.1.5
 ---> Using cache
 ---> a3df9ec9618a
Step 8/34 : RUN docker-php-ext-enable memcached
 ---> Using cache
 ---> 6b9823c098f2
Step 9/34 : RUN pecl install mcrypt-1.0.3
 ---> Using cache
 ---> 5afdb1065c94
Step 10/34 : RUN docker-php-ext-enable mcrypt
 ---> Using cache
 ---> 32333fa664e4
Step 11/34 : RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp
 ---> Using cache
 ---> 2b6129a58a34
Step 12/34 : RUN docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd
 ---> Using cache
 ---> 75fa3aa8a478
Step 13/34 : RUN docker-php-ext-configure mysqli --with-mysqli=mysqlnd
 ---> Using cache
 ---> b05ca83570bd
Step 14/34 : RUN docker-php-ext-configure intl
 ---> Using cache
 ---> 0e99559690e5
Step 15/34 : RUN docker-php-ext-configure zip
 ---> Using cache
 ---> 18ff0128468f
Step 16/34 : RUN docker-php-ext-install -j$(nproc) gd
 ---> Using cache
 ---> 79565039e24c
Step 17/34 : RUN docker-php-ext-install -j$(nproc) opcache
 ---> Using cache
 ---> 903826b99ebe
Step 18/34 : RUN docker-php-ext-install -j$(nproc) pdo_mysql
 ---> Using cache
 ---> 5d4abd96554d
Step 19/34 : RUN docker-php-ext-install -j$(nproc) mysqli
 ---> Using cache
 ---> 86b0df8b0edc
Step 20/34 : RUN docker-php-ext-install -j$(nproc) intl
 ---> Using cache
 ---> 1db646fdea7f
Step 21/34 : RUN docker-php-ext-install -j$(nproc) zip
 ---> Using cache
 ---> 6571cab2d25d
Step 22/34 : RUN pecl install xdebug
 ---> Using cache
 ---> c2be660325e5
Step 23/34 : RUN docker-php-ext-enable xdebug
 ---> Using cache
 ---> 0da2c29166d3
Step 24/34 : RUN echo "xdebug.remote_enable=1" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
 ---> Using cache
 ---> f0915cbbfcdb
Step 25/34 : RUN echo "xdebug.remote_autostart=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
 ---> Using cache
 ---> 6f3e1b9f5410
Step 26/34 : RUN echo "xdebug.default_enable=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
 ---> Using cache
 ---> 55930a6f11ec
Step 27/34 : RUN echo "xdebug.remote_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
 ---> Using cache
 ---> 863fda3ad624
Step 28/34 : RUN echo "xdebug.remote_port=9000" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
 ---> Using cache
 ---> 6635d8bd4f98
Step 29/34 : RUN echo "xdebug.remote_connect_back=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
 ---> Using cache
 ---> 1194e824fb21
Step 30/34 : RUN echo "xdebug.profiler_enable=0" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
 ---> Using cache
 ---> 78b01375d5f4
Step 31/34 : RUN echo "xdebug.remote_log=\"/tmp/xdebug.log\"" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
 ---> Using cache
 ---> 02dd6b378527
Step 32/34 : RUN pecl install imagick
 ---> Using cache
 ---> 3139cfd7b24d
Step 33/34 : RUN docker-php-ext-enable imagick
 ---> Using cache
 ---> 46585c525b84
Step 34/34 : RUN cd /tmp     && curl -sS https://getcomposer.org/installer | php     && mv composer.phar /usr/local/bin/composer
 ---> Using cache
 ---> eed8993fad91
Successfully built eed8993fad91
Successfully tagged php:gd
$ docker run --rm php:gd php -r 'print_r(gd_info());'
Array
(
    [GD Version] => bundled (2.1.0 compatible)
    [FreeType Support] => 1
    [FreeType Linkage] => with freetype
    [GIF Read Support] => 1
    [GIF Create Support] => 1
    [JPEG Support] => 1
    [PNG Support] => 1
    [WBMP Support] => 1
    [XPM Support] => 
    [XBM Support] => 1
    [WebP Support] => 1
    [BMP Support] => 1
    [TGA Read Support] => 1
    [JIS-mapped Japanese Font Support] => 
)

Also the RUN apt-get clean has to be in the same RUN line, previous layers can't be altered in later layers as the size doesn't change, so I added the usual rm -rf /var/lib/apt/lists/*

@paulocoutinhox
Copy link
Author

Hi,

Yes, changing the order make compilation works too.

Thanks.

@yosifkit
Copy link
Member

yosifkit commented Jan 1, 2020

Closing, seems to be resolved.

@yosifkit yosifkit closed this as completed Jan 1, 2020
@paulocoutinhox
Copy link
Author

Yes, was resolved, changing the order too.

Thanks.

@shyamjos
Copy link

shyamjos commented Aug 6, 2020

Moving GD to the top fixed my issue too , is this a bug in docker php extension installer script?

@tianon
Copy link
Member

tianon commented Aug 12, 2020

I thought this was odd, but had an epiphany this morning -- it's not a "bug" of docker-php-ext-install, but rather a feature:

docker-php-source delete

When it finishes working, docker-php-ext-install will delete the source code (which includes all the bits configured by docker-php-ext-configure). The intention is that you run docker-php-ext-configure some number of times, then run a single invocation of docker-php-ext-install (because there's really no reason to run those separately); also, it would be good to run them all in the same layer so the image doesn't bloat with the size of the PHP source code:

# configure, install and enable all php packages
RUN set -eux; \
	docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg --with-webp; \
	docker-php-ext-configure intl; \
	docker-php-ext-configure mysqli --with-mysqli=mysqlnd; \
	docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd; \
	docker-php-ext-configure zip; \
	docker-php-ext-install -j "$(nproc)" \
		gd \
		intl \
		mysqli \
		opcache \
		pdo_mysql \
		zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Usability question, not directly related to an error with the image
Projects
None yet
Development

No branches or pull requests

6 participants