Search code examples
phpdockergitlabgitlab-cigitlab-ci-runner

GitLab PHP docker image - the requested PHP extension gd is missing from your system


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?


Solution

  • 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
    ...