This is my docker file:
FROM php:8.0-fpm-buster
# Arguments defined in docker-compose.yml
ARG user
ARG uid
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
git \
curl \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
jpegoptim optipng pngquant gifsicle \
libonig-dev \
libxml2-dev \
zip \
sudo \
unzip \
npm \
nodejs \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd
but I have an error
Call to undefined function Intervention\Image\Gd\imagecreatefromjpeg()
when i try to upload a jpg image.Even I change it to:
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-gd --with-freetype --with-jpeg \
but I have below error when I build and the above error in Laravel
configure: error: unrecognized options: --with-freetype-dir, --with-jpeg-dir, --with-gd ------ failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c apt-get update && apt-get install -y
build-essential git curl libpng-dev libjpeg-dev
libfreetype6-dev libjpeg62-turbo-dev jpegoptim optipng pngquant gifsicle libonig-dev libxml2-dev zip sudo
unzip npm nodejs && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ --with-gd --with-freetype --with-jpeg && docker-php-ext-install -j$(nproc) gd]: exit code: 1
how can I fix this?
I fix it by enabling the GD lib, here is my Dockerfile configs:
FROM php:8.0-fpm-buster
# Arguments defined in docker-compose.yml
ARG user
ARG uid
# Install system dependencies
RUN apt-get update && apt-get install -y \
build-essential \
git \
curl \
libpng-dev \
libjpeg-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libgd-dev \
jpegoptim optipng pngquant gifsicle \
libonig-dev \
libxml2-dev \
zip \
sudo \
unzip \
npm \
nodejs
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
# Install PHP extensions
RUN docker-php-ext-configure gd --enable-gd --with-freetype --with-jpeg
RUN docker-php-ext-install pdo_mysql mbstring exif pcntl bcmath gd