John Davidson

docker - No JPEG support in this PHP build

0 comments
Message:


I'm trying to setup my docker environment so I could run my phpUnit tests, I get and error No JPEG support in this PHP build while loading fixtures with pictures, I have gd extension installed but for some reason JPEG support is disabled even when I give it a flag to enable it during the instalation. I tried every solution I could find on stackoverflow but none of them helped. What am I doing wrong?


Script that installs gd extension gd-install.sh:


[[ ! -e /.dockerenv ]] && exit 0

apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
&& docker-php-ext-install -j$(nproc) gd

Info I get after running installation and php -r 'print_r(gd_info());' command.


[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] =>

How I launch installation script from .gitlab-ci.yml file :


default:
image: php:7.4-fpm
services:
- name: mysql:5.7
alias: mysql

cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- vendor/

phpunit:
stage: test
script:
- sh scripts/ci-php-install.sh
- sh scripts/gd-install.sh
- docker-php-ext-install bcmath
- docker-php-ext-install sockets
- docker-php-ext-install gd
- sh scripts/zip-install.sh
- sh scripts/env-setup.sh
- php -r 'print_r(gd_info());'
- php composer.phar install -o
- php composer.phar require --dev symfony/phpunit-bridge
- sh scripts/php_test_run.sh

stages:
- test


My Answer:
This issue could be related to the specific PHP build you are using in your Docker environment. It's possible that the PHP build you are using does not have JPEG support enabled by default.

One possible solution is to try using a different PHP build that has JPEG support enabled. You can search for a PHP Docker image that specifically includes JPEG support or try building your own Docker image with JPEG support enabled.

Another solution is to manually enable JPEG support in your current PHP build. You can do this by recompiling PHP with the `--with-jpeg` flag during installation. You may need to modify your `gd-install.sh` script to include this flag.

Here is an example of how you can modify your `gd-install.sh` script to include JPEG support:

bash
#!/bin/bash

apt-get update
apt-get install -y libjpeg-dev

docker-php-ext-configure gd --with-jpeg
docker-php-ext-install gd


After modifying your script, rebuild your Docker image and try running your phpUnit tests again. This should enable JPEG support in your PHP build and allow you to load fixtures with pictures successfully.

Rate this post

3 of 5 based on 4704 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us