Make php-fpm forward environment variables

By default php-fpm has `clear_env` option activated.

This means that environment variables never will be passed on from the
system environment to the actual worker process for a given request.

This also means that Grocy will not be configureable via Environment
variables. Which is very common behaviour.

We can fix this by disabling the `clear_env`.

You can test that it works by for example changing the currency via an
environment variable:

  docker run -e GROCY_CURRENCY=NOK -p 8080:80 linuxserver/grocy:latest

Then opening:

  http://localhost:8080/stockoverview

And verifying that the app allows you to change the setting. There's
more info on how Grocy handles configuration, here:

  https://github.com/grocy/grocy/blob/master/config-dist.php#L3
This commit is contained in:
Benedicte Emilie Brækken 2024-03-29 13:39:41 +01:00
parent 1031528013
commit b0f407bab5
3 changed files with 7 additions and 0 deletions

View File

@ -22,6 +22,9 @@ RUN \
php83-pdo \
php83-pdo_sqlite \
php83-tokenizer && \
echo "**** configure php-fpm to pass env vars ****" && \
sed -E -i 's/^;?clear_env ?=.*$/clear_env = no/g' /etc/php83/php-fpm.d/www.conf && \
grep -qxF 'clear_env = no' /etc/php83/php-fpm.d/www.conf || echo 'clear_env = no' >> /etc/php83/php-fpm.d/www.conf && \
echo "**** install grocy ****" && \
mkdir -p /app/www && \
if [ -z ${GROCY_RELEASE+x} ]; then \

View File

@ -22,6 +22,9 @@ RUN \
php83-pdo \
php83-pdo_sqlite \
php83-tokenizer && \
echo "**** configure php-fpm to pass env vars ****" && \
sed -E -i 's/^;?clear_env ?=.*$/clear_env = no/g' /etc/php83/php-fpm.d/www.conf && \
grep -qxF 'clear_env = no' /etc/php83/php-fpm.d/www.conf || echo 'clear_env = no' >> /etc/php83/php-fpm.d/www.conf && \
echo "**** install grocy ****" && \
mkdir -p /app/www && \
if [ -z ${GROCY_RELEASE+x} ]; then \

View File

@ -41,6 +41,7 @@ app_setup_block: |
# changelog
changelogs:
- { date: "29.03.24:", desc: "Add `clear_env = no` to `php-fpm` to pass on environment variables to workers threads" }
- { date: "06.03.24:", desc: "Existing users should update: site-confs/default.conf - Cleanup default site conf." }
- { date: "06.03.24:", desc: "Rebase to Alpine 3.19 with php 8.3."}
- { date: "25.05.23:", desc: "Rebase to Alpine 3.18, deprecate armhf." }