Docker problems with ext-gd

I am using a manjaro system and installed invoiceplan like that:

wget https://github.com/InvoicePlane/InvoicePlane/releases/download/v1.6.0/v1.6.0.zip
unzip v1.6.0.zip
cd ./InvoicePlane-1.6.0
docker-compose up -d
cp ipconfig.php.example ipconfig.php

I enabled extension=gd in /etc/php/php.ini. Also, i installed php-gd sudo pacman -S php-gd. Running Now i try to run composer install (in InvoicePlane-1.6.0 folder) with this error:

[user@system InvoicePlane-1.6.0]$ composer install
PHP Warning:  PHP Startup: Unable to load dynamic library 'gd' (tried: /usr/lib/php/modules/gd (/usr/lib/php/modules/gd: cannot open shared object file: No such file or directory), /usr/lib/php/modules/gd.so (/usr/lib/php/modules/gd.so: undefined symbol: zend_unregister_ini_entries_ex)) in Unknown on line 0
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Your lock file does not contain a compatible set of packages. Please run composer update.

  Problem 1
    - Root composer.json requires PHP extension ext-gd * but it is missing from your system. Install or enable PHP's gd extension.
  Problem 2
    - mpdf/mpdf is locked to version v8.1.6 and an update of this package was not requested.
    - mpdf/mpdf v8.1.6 requires ext-gd * -> it is missing from your system. Install or enable PHP's gd extension.
  Problem 3
    - setasign/fpdf is locked to version 1.8.6 and an update of this package was not requested.
    - setasign/fpdf 1.8.6 requires ext-gd * -> it is missing from your system. Install or enable PHP's gd extension.

To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/php.ini
You can also run `php --ini` in a terminal to see which files are used by PHP in CLI mode.
Alternatively, you can run Composer with `--ignore-platform-req=ext-gd` to temporarily ignore these required extensions.

php --ini shows the correct path:

PHP Warning:  PHP Startup: Unable to load dynamic library 'gd' (tried: /usr/lib/php/modules/gd (/usr/lib/php/modules/gd: cannot open shared object file: No such file or directory), /usr/lib/php/modules/gd.so (/usr/lib/php/modules/gd.so: undefined symbol: zend_unregister_ini_entries_ex)) in Unknown on line 0
Configuration File (php.ini) Path: /etc/php
Loaded Configuration File:         /etc/php/php.ini
Scan for additional .ini files in: /etc/php/conf.d
Additional .ini files parsed:      (none)

We can also see the gd.so file:

[user@system InvoicePlane-1.6.0]$ ls /usr/lib/php/modules/
bcmath.so  bz2.so  calendar.so  curl.so  dba.so  exif.so  ffi.so  ftp.so  gd.so  gettext.so  gmp.so  iconv.so  ldap.so  mysqli.so  opcache.so  pdo_mysql.so  shmop.so  soap.so  sockets.so  sysvmsg.so  sysvsem.so  sysvshm.so  zip.so

Hi @fnu, you can run the following command to fix it:
composer install --ignore-platform-req=ext-gd
Also i would recommend following this installation method:
https://wiki.invoiceplane.org/en/1.5/getting-started/installation

Running composer install --ignore-platform-req=ext-gd leads to

[user@system InvoicePlane-1.6.0]$  composer install --ignore-platform-req=ext-gd
PHP Warning:  PHP Startup: Unable to load dynamic library 'gd' (tried: /usr/lib/php/modules/gd (/usr/lib/php/modules/gd: cannot open shared object file: No such file or directory), /usr/lib/php/modules/gd.so (/usr/lib/php/modules/gd.so: undefined symbol: zend_unregister_ini_entries_ex)) in Unknown on line 0
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Nothing to install, update or remove
Package php-http/message-factory is abandoned, you should avoid using it. Use psr/http-factory instead.
Generating autoload files
18 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

So again Unable to load dynamic library 'gd'.

About the installation method: I want to run this inside a docker container (this has dependency reasons and thus is not optional).

3 posts were split to a new topic: Docker problems with MariaDB container

@fnu welcome to the forums
Did you try the default docker-compose.yml. just plain docker-compose up -d`

It should install that library. The Dockerfile is in resources/docker/php-fpm

What do you mean with “just plain”? I only run the normal docker compose up -d command.

@fnu I’ve split your problem with MariaDB to a separate topic.
Now I need to reproduce your problem with the gd library, so bare with me.

1 Like

So … by now I did the following:
Change the ipfnu.conf in resources/docker/nginx/ipfnu.conf to reflect the listening port on 8083
docker-compose up -d
http://ipfnu.local:8083/ and ran through the setup
It completely installed InvoicePlane
I “entered” the php docker container:
docker-compose exec -it --user=www-data php /bin/bash
php --ini:


And php --modules | grep gd:

I discovered a few bugs in this whole ordeal.
I’ve added 2 of them to the github issues list.
1 extra bug is reproduced:

After installing InvoicePlane the Encryption Key isn’t written to ipconfig.php

What is this ipfnu.conf file? Sound like a custom file i guess (because of fnu?)? Could you please show me the exact content of this file?

[user@system InvoicePlane-1.6.0]$ ls ./resources/docker/nginx/
Dockerfile  invoiceplane.conf  nginx.conf

You’re right, i was too quick:
Just copy invoiceplane.conf to ipfnu.conf and do the listen 8083

Let me know if the custom config works out for you.

With the custom .conf files I also change the log files:

    error_log /var/log/nginx/ivpl_error.log;
    access_log /var/log/nginx/ivpl_access.log;

Don’t forget to also change your docker-compose.yml:
- ./resources/docker/nginx/ipfnu.conf:/etc/nginx/conf.d/ipfnu.conf:ro

#server {
#    listen 80;
#    server_name copyme.com.co;
#    return 301 https://copyme.com.co$request_uri;
#}

server {

    listen 8083;

    server_name ipfnu.local;
    root /var/www/projects/invoiceplane;
    index index.php index.html index.htm;

    location / {
         try_files $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_pass php-upstream;
        fastcgi_index index.php;
        fastcgi_buffers 16 16k;
        fastcgi_buffer_size 32k;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #fixes timeouts
        fastcgi_read_timeout 600;
        include fastcgi_params;
    }

    location ~ /\.ht {
        deny all;
    }

    location /.well-known/acme-challenge/ {
        root /var/www/letsencrypt/;
        log_not_found off;
    }

    error_log /var/log/nginx/ivpl_error.log;
    access_log /var/log/nginx/ivpl_access.log;
}

Seems like i have some trouble again. So my systems name is nuc:

[user@nuc InvoicePlane-1.6.0]$ cd ./resources/docker/nginx/
[user@nuc nginx]$ ls
Dockerfile  invoiceplane.conf  nginx.conf
[user@nuc nginx]$ cp invoiceplane.conf ipnuc.conf

Change ipnuc.conf to this:

… also editing this line in docker.compose.yml file at the nginx part: - ./resources/docker/nginx/ipnuc.conf:/etc/nginx/conf.d/ipnuc.conf:ro

running docker-compose up -d --build nginx:


[user@nuc nginx]$ docker ps -a
CONTAINER ID   IMAGE                                                   COMMAND                  CREATED         STATUS                      PORTS                                                 NAMES
606c8f1b52c9   invoiceplane-160_nginx                                  "/docker-entrypoint.…"   4 minutes ago   Up 4 minutes                443/tcp, 0.0.0.0:8083->80/tcp, :::8083->80/tcp        invoiceplane-nginx
b57b0e17e0be   invoiceplane-160_db                                     "docker-entrypoint.s…"   5 hours ago     Up 5 hours                  0.0.0.0:3306->3306/tcp, :::3306->3306/tcp             invoiceplane-db
79f85cbc92bc   invoiceplane-160_phpmyadmin                             "/docker-entrypoint.…"   7 hours ago     Up 7 hours                  0.0.0.0:8086->80/tcp, :::8086->80/tcp                 invoiceplane-dbadmin
409d4fa13df9   invoiceplane-160_php                                    "docker-php-entrypoi…"   7 hours ago     Up 7 hours                  9000/tcp                                              invoiceplane-php

open http://nuc:8083/ in browser → error

What is the error? The one of not loading any page at all? I’ll have to look next weekend

Error: Connection failed

Firefox cannot connect to the server at nuc:8083.

Ok, make it http://nuc.local:8083 and try again.
Check your /etc/hosts file, to see if nuc.local is there as well.
I saw in your screenshot that your .conf file was also pointing to nuc.local

tbh my hostname is not nuc.local but nuc. I can reach all my services with nuc:specific-port in browser. I removed the .local part in .conf and try to reach the weboverlay with nuc:8083 - no success. Again, all my other services are reachable under nuc:specific-port.

I’ve sent you 2 setups for your special url.
They’re .zip files so you can place them in the right directories locally.

Unfortunately I can’t make your setup work with just http://nuc:8083
I’ve made the .zips for you with http://nuc.local:8083

If anyone else wants to have a go at this user’s problem, feel free.

The problem with ext-gd is differently than I thought:

  • in the current Docker setup the composer isn’t installed.

The solution is:

  • Install composer in the current php-fpm Dockerfile (That’s an issue that needs to be taken care of in our InvoicePlane repository and in the new .zip file for Beta-3)
  • After cloning the repo or downloading the .zip run docker-compose up -d
  • After all containers are running: docker-compose exec -it --user=www-data php /bin/bash
  • Then run composer install (if you’ve cloned the repo, the .zip file has already ran composer install)
  • It will install the packages, including the mpdf package, which requires ext-gd