Home > Software design >  Installing php7.3:GD ext Freetype and JPEG Support
Installing php7.3:GD ext Freetype and JPEG Support

Time:05-20

I'm new in docker and im trying to install GD extension with freetype and jpeg support , but when installed , always like this...

[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
    [JIS-mapped Japanese Font Support] => 

jpeg and freetype doesn't want to be installed

btw this is my docker file

app.dockerfile

FROM php:7.3-fpm-buster

RUN sed -i 's/9000/3004/' /usr/local/etc/php-fpm.d/zz-docker.conf

RUN apt-get update && apt-get install -y libpq-dev git \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng-dev libxpm-dev \
    libwebp-dev \
    libldap2-dev \
    libmagickwand-dev \
    libgd3 \
    libgd-dev \
    zlib1g-dev \
    libzip-dev \
    --no-install-recommends && apt-get clean && rm -r /var/lib/apt/lists/*

RUN docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr \
    && docker-php-ext-configure ldap --with-libdir=lib/$(uname -m)-linux-gnu/ \
    && docker-php-ext-install ldap gd pdo pdo_pgsql pgsql intl pcntl zip bcmath \
    && docker-php-ext-install gd \
    && docker-php-ext-install exif \
    && pecl install redis && docker-php-ext-enable redis \
    && pecl install imagick && docker-php-ext-enable imagick

RUN ln -fs /usr/share/zoneinfo/Asia/Jakarta /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata


## imagemagick sepertinya belum berjalan dengan lancar di php8 (05 Feb 2021)
## https://github.com/Imagick/imagick/issues/331
## -------------------------------------------------------------------------

COPY ./docker/php.ini /usr/local/etc/php/php.ini

WORKDIR /var/www

USER nobody

queue.dockerfile

FROM php:7.3-cli-buster

RUN apt-get update && apt-get install -y libpq-dev git \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng-dev libxpm-dev \
    libwebp-dev \
    libldap2-dev \
    libmagickwand-dev \
    libgd3 \
    libgd-dev \
    zlib1g-dev \
    libzip-dev \
    --no-install-recommends && apt-get clean && rm -r /var/lib/apt/lists/*

RUN docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr \
    && docker-php-ext-configure ldap --with-libdir=lib/$(uname -m)-linux-gnu/ \
    && docker-php-ext-install ldap gd pdo pdo_pgsql pgsql intl pcntl zip bcmath \
    && docker-php-ext-install gd \
    && docker-php-ext-install exif \
    && pecl install redis && docker-php-ext-enable redis \
    && pecl install imagick && docker-php-ext-enable imagick

## imagemagick sepertinya belum berjalan dengan lancar di php8 (05 Feb 2021)
## https://github.com/Imagick/imagick/issues/331
## -------------------------------------------------------------------------

RUN ln -fs /usr/share/zoneinfo/Asia/Jakarta /etc/localtime && \
    dpkg-reconfigure -f noninteractive tzdata

COPY ./docker/php.ini /usr/local/etc/php/php.ini

WORKDIR /var/www

USER nobody

entrypoint ["php", "artisan", "queue:work", "--sleep=3", "--tries=3", "--max-time=1800"]

composer.dockerfile

FROM php:7.3-cli-buster

COPY --from=composer/composer /usr/bin/composer /usr/bin/composer

RUN apt-get update && apt-get install -y libpq-dev git \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng-dev libxpm-dev \
    libwebp-dev \
    libldap2-dev \
    libmagickwand-dev \
    libgd3 \
    libgd-dev \
    zlib1g-dev \
    libzip-dev \
    unzip \
    --no-install-recommends && apt-get clean && rm -r /var/lib/apt/lists/*

RUN docker-php-ext-configure gd --with-freetype-dir=/usr --with-jpeg-dir=/usr \
    && docker-php-ext-configure ldap --with-libdir=lib/$(uname -m)-linux-gnu/ \
    && docker-php-ext-install pdo pdo_pgsql pgsql intl pcntl zip bcmath \
    && docker-php-ext-install gd \
    && docker-php-ext-install exif \
    && pecl install redis && docker-php-ext-enable redis \
    && pecl install imagick && docker-php-ext-enable imagick

# imagemagick sepertinya belum berjalan dengan lancar di php8 (05 Feb 2021)
# https://github.com/Imagick/imagick/issues/331
# -------------------------------------------------------------------------

WORKDIR /app

CMD ["composer"]

if i may know what could be the problem and how could I fix it?

CodePudding user response:

Seems to me that Dockerfile should looks like this:

FROM php:7.3-fpm-buster

# Install dependencies
RUN apt-get update && apt-get install -y \
    libpng-dev \
    libjpeg62-turbo-dev \
    libfreetype6-dev \
    jpegoptim optipng pngquant gifsicle 

RUN apt-get update && apt-get install -y --no-install-recommends libmagickwand-dev
RUN pecl install imagick && docker-php-ext-enable imagick
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* || true

# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# Install extensions
RUN docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ \
    && docker-php-ext-install gd
RUN docker-php-ext-install gd

CodePudding user response:

I can give you my working Dockerfile, you have to adjust some values for sure though, and there is a mongodb extension as well:

FROM php:8.0-fpm-alpine3.12

$PHP_INI_DIR/php.ini

ENV EXT_MONGODB_VERSION=1.9.1

RUN docker-php-source extract \
    && apk update && apk add git \
    && git clone --branch $EXT_MONGODB_VERSION --depth 1 https://github.com/mongodb/mongo-php-driver.git /usr/src/php/ext/mongodb \
    && cd /usr/src/php/ext/mongodb && git submodule update --init \
    && docker-php-ext-install mongodb

RUN docker-php-ext-install mysqli pdo_mysql

RUN apk add freetype-dev libpng libpng-dev jpeg-dev libjpeg-turbo-dev libwebp-dev zlib-dev libxpm-dev

RUN apk add --no-cache $PHPIZE_DEPS \
    && pecl install xdebug-3.1.0 \
    && docker-php-ext-enable xdebug

RUN docker-php-ext-configure gd \
        --with-freetype=/usr/lib/ \
        --with-jpeg=/usr/lib/

RUN docker-php-ext-install gd

RUN touch /var/log/php_error.log
  • Related