phpdockersymfonygd

Docker symfony and gd extension


I'm trying to add the GD extension to my php on my symfony project. My symfony project is configured with docker via this package https://github.com/dunglas/symfony-docker on windows with WSL. But when I run the “docker-php-ext-install gd” command, I get this error:

Package 'zlib', required by 'virtual:world', not found

Unfortunately, I don't really understand what I'm supposed to do.

I tried adding this to my Dockerfile:

    RUN apk add --no-cache \
    zlib-dev \
    libpng-dev
    build-base
    wget
    tar
    make
&& wget https://github.com/libgd/libgd/releases/download/gd-2.3.3/libgd-2.3.3.tar.gz \
&& tar -xf libgd-2.3.3.tar.gz \
&& cd libgd-2.3.3 \
&& ./configure --with-freetype --with-jpeg \
&& make \
&& make install \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd zlib

But it doesn't seem to work. Thank you for your help.


Solution

  • As mentioned in this issue, the zlib1g-dev is missing.

    RUN apk add --no-cache \
        zlib-dev \
        zlib1g-dev \ 
        libpng-dev \
        build-base \
        wget \
        tar \
        make \
    && wget https://github.com/libgd/libgd/releases/download/gd-2.3.3/libgd-2.3.3.tar.gz \
    && tar -xf libgd-2.3.3.tar.gz \
    && cd libgd-2.3.3 \
    && ./configure --with-freetype --with-jpeg \
    && make \
    && make install \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd zlib