From b0f407bab5605fdcd67ea2f44378663acdfca8f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benedicte=20Emilie=20Br=C3=A6kken?= Date: Fri, 29 Mar 2024 13:39:41 +0100 Subject: [PATCH] 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 --- Dockerfile | 3 +++ Dockerfile.aarch64 | 3 +++ readme-vars.yml | 1 + 3 files changed, 7 insertions(+) diff --git a/Dockerfile b/Dockerfile index ad3f263..a30c8b4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 \ diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 19fe570..e2e7ef8 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -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 \ diff --git a/readme-vars.yml b/readme-vars.yml index 10ed543..539b24c 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -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." }