3

I'm writing some unit tests for our application and we're using GitLab CI with GitLab Runner v11.11.1 and using Docker executor with image php:7.1.

When running composer install (our composer version is 1.10.17) I get the following error on a few required packages:

the requested PHP extension gd is missing from your system

I've tried a couple things like on our gitlab-ci.yml:

apt-get update -yqq
apt-get install -yqq libpng-dev

But that also produced the same error.

I also tried requiring ext-gd from the composer.json file:

composer require ext-gd

But I got this error:

The requested PHP extension ext-gd ^7.1 is missing from your system. Install or enable PHP's gd extension.

The last attempt I made was:

apt-get install php-common
phpenmod gd

But this gave me this error:

Unable to locate package php-common


Does anyone know how to simply enable the PHP extension gd so I can run my unit tests?

dokgu
  • 4,957
  • 3
  • 39
  • 77

2 Answers2

3

I fixed the errors when I added this to my gitlab-ci.yml file:

...
before_script:
  - apt-get update -yqq
  - apt-get install libjpeg-dev libpng-dev -yqq
  - docker-php-ext-install gd
... 
dokgu
  • 4,957
  • 3
  • 39
  • 77
0

You need PHP GD library. For Debian and Debian based systems, e.g. Ubuntu, as well as Debian based Docker containers use:

apt-get install -qy php-gd

If it's still unclear, or you have older/other system just search

apt-cache search php gd

and will find out possible package candidates.

For Docker containers it seems you need a different route, so Dockerfile:

FROM php:7.1-apache-buster
RUN apt-get update
RUN apt-get upgrade -qqy
RUN php -v
RUN apt-get install -qy libpng-dev
RUN docker-php-ext-install gd
Arunas Bartisius
  • 1,879
  • 22
  • 23