I try to run laravel with media-library under docker(with PHP Version 8.1.4) and when I try to get properties of image with code :
if ( ! empty($CMSItemMedia) and File::exists($CMSItemMedia->getPath())) {
$CMSItemImage['url'] = $CMSItemMedia->getUrl();
\Log::info( varDump($CMSItemMedia->getUrl(), ' -1 $CMSItemMedia->getUrl()::') );
$imageInstance = Image::load($CMSItemMedia->getUrl());
\Log::info( varDump($imageInstance, ' -1 $imageInstance::') );
$CMSItemImage['width'] = $imageInstance->getWidth();
I got next logging lines and error :
[2022-05-31 13:37:20] local.INFO: scalar => (string) : -1 $CMSItemMedia->getUrl():: : http://127.0.0.1:8088/storage/currency_app/21/our_rules.png
[2022-05-31 13:37:20] local.INFO: (Object of Spatie\Image\Image) : -1 $imageInstance:: : Array
(
[manipulations] => Spatie\Image\Manipulations Object
(
[manipulationSequence:protected] => Spatie\Image\ManipulationSequence Object
(
[groups:protected] => Array
(
[0] => Array
(
)
)
)
)
[imageDriver] => gd
[temporaryDirectory] =>
[optimizerChain] =>
[pathToImage] => http://127.0.0.1:8088/storage/currency_app/21/our_rules.png
)
[2022-05-31 13:37:20] local.ERROR: Unable to init from given url (http://127.0.0.1:8088/storage/currency_app/21/our_rules.png). {"exception":"[object] (Intervention\\Image\\Exception\\NotReadableException(code: 0): Unable to init from given url (http://127.0.0.1:8088/storage/currency_app/21/our_rules.png). at /var/www/BiCurrencies_DOCKER_ROOT/vendor/intervention/image/src/Intervention/Image/AbstractDecoder.php:85)
[stacktrace]
If to open file in browser url
http://127.0.0.1:8088/storage/currency_app/21/our_rules.png
file is opened ok.
In phpinfo output I see that gd is intalled in my docker OS :
GD Support enabled
GD Version bundled (2.1.0 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.10.4
I have in my app :
"spatie/laravel-medialibrary": "^10.0.0",
"intervention/image": "^2.7",
and in .env :
APP_URL=http://127.0.0.1:8088
so my app runs by http://127.0.0.1:8088 url.
In Dockerfile.yml file I have gd installed :
FROM php:8.1.4-apache
RUN apt-get update && \
apt-get install --assume-yes --no-install-recommends --quiet \
python \
libfreetype6-dev \
libwebp-dev \
libjpeg62-turbo-dev \
libpng-dev \
libzip-dev \
nano \
mc \
git-core \
libmagickwand-dev \
curl \
build-essential \
libnotify-bin \
openssl \
libssl-dev \
libgmp-dev \
libldap2-dev \
netcat \
locate \
# composer \
&& git clone https://github.com/nodejs/node.git && \
cd node \
&& git checkout v14.18.0 \
&& ./configure \
&& make \
&& make install
RUN pecl install imagick \
&& docker-php-ext-enable imagick
RUN npm install cross-env
RUN npm install -g yarn
RUN docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp --with-jpeg
RUN docker-php-ext-install gd
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN docker-php-ext-install pdo pdo_mysql zip gmp bcmath pcntl ldap sysvmsg exif \
&& a2enmod rewrite
RUN apt-get install -y grep mlocate
COPY virtualhost.conf /etc/apache2/sites-enabled/000-default.conf
I do not have such problems under hosting Kubuntu 20.
What is wrong ? Did I miss some docker options ?
Thanks!