mdshack / shotshare

Open source image sharing application
https://demo.shotshare.dev/
MIT License
133 stars 8 forks source link

fix: correct .ini path so that environment variable overrides are honoured #64

Closed bentasker closed 1 month ago

bentasker commented 2 months ago

The current logic reads environment variables and writes them into /etc/php.d/environment.ini.

The entrypoint then passes php-fpm this the parent directory as a config dir:

php-fpm -c /etc/php.d/

However, php-fpm will not read environment.ini. You can confirm this by setting the variables high and creating a large "image" to upload:

dd if=/dev/random of=test.jpg bs=1M count=15

If you hit the UI, signup and try and upload, you'll receive a PHP error message which includes

exceeds the limit of 8388608 bytes

The limit is still at 8M.

Checking php-fpm --help shows that it's looking for a file called php.ini.

php-fpm --help
Usage: php [-n] [-e] [-h] [-i] [-m] [-v] [-t] [-p <prefix>] [-g <pid>] [-c <file>] [-d foo[=bar]] [-y <file>] [-D] [-F [-O]]
  -c <path>|<file> Look for php.ini file in this directory

Adjusting the init script to instead write to php.ini works, but comes at the cost of losing any other settings which have been configured in /usr/local/etc/php/php.ini-production

Because the settings generated by the init script are additive, it probably makes more sense to drop them into /usr/local/etc/php/conf.d/, so that is what this PR does