PHP Fatal Error (allocating memory) when uploading a logo

Hello everyone,
I’ve just set up a fresh Docker install of InvoiceNinja (latest) and everything seems to be working OK except for logo uploads.

First, some logs:

From “app”

NOTICE: PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 111050752 bytes) in /var/www/app/app/Jobs/Util/UploadAvatar.php on line 40

From “server”

023/04/11 22:19:26 [warn] 29#29: *466 a client request body is buffered to a temporary file /var/cache/nginx/client_temp/0000000002, client: 172.23.0.1, server: _, request: "POST /api/v1/companies/VolejRejNm HTTP/1.1", host: "example.net", referrer: "https://example.net/"
2023/04/11 22:19:26 [error] 29#29: *466 FastCGI sent in stderr: "PHP message: PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 111050752 bytes) in /var/www/app/app/Jobs/Util/UploadAvatar.php on line 40" while reading response header from upstream, client: 172.23.0.1, server: _, request: "POST /api/v1/companies/VolejRejNm HTTP/1.1", upstream: "fastcgi://172.23.0.3:9000", host: "example.net", referrer: "https://example.net/"

I’ve been searching around the forums and most recommend changing the PHP max upload size. From prior PHP (non-docker) projects this has been a resolution, however, the only accessible file ./alpine/5/rootfs/usr/local/etc/php/conf.d/in-php.ini (changed from 8M to 256M) did not seem to make a difference. If there is another php.ini file (not mapped outside of docker) then that may be it.

It should also be noted that I am using an nginx reverse proxy outside of docker. Excerpt below:

location / {
                proxy_pass http://127.0.0.1:<internal_port>;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Nginx-Proxy true;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "Upgrade";
                proxy_set_header Host $http_host;
                client_max_body_size 256M;
                proxy_redirect off;
        }

The compose file maps <internal_port> to 80 but otherwise it is unchanged from the default file given. I may have screwed up this reverse proxy somewhat, and that could contribute to the root cause here. For example, APP_URL=http://in.localhost and hosts: 192.168.0.124 in5.test and the config/nginx/in-vhost.conf (unchanged).

Any help would be appreciated or if more information is required I can provide it. Again, it’s accessible via the reverse proxy currently and functionally seems fine other than the logo upload.

Edit: This also affects the client portal. Some elements will load (seems to be basic HTML with some images much too large) but specifically I see an error about being unable to connect to “in.localhost” from APP_URL.

Edit 2: Changing APP_URL to the https://example.net fixed the client portal but did not fix the logo upload issue.

How large is your logo? I haven’t seen a OOM for a logo upload breaking 128Mb of memory.

Wow.

Can’t believe I failed at my most basic troubleshooting. These were all PNG files under 1M so the space part did not make sense. But reading your comment, I tried another logo, similar image size (under 1M) but the dimensions were drastically reduced (8192 × 3389 → 2188 × 876) and, sure enough, it worked.

Looks like we are all good to go.

Solution: Check your image dimensions!