From 3b2aa1ca2e8a4ce90841bb760adadc145a951939 Mon Sep 17 00:00:00 2001 From: Darko Gjorgjijoski <5760249+gdarko@users.noreply.github.com> Date: Wed, 29 Jul 2026 12:23:20 +0200 Subject: [PATCH] fix(config): make the application timezone configurable (#703) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes InvoiceShelf/docker#64 — recurring invoices and scheduled tasks running on the wrong timezone. Two bugs compounded so that no supported value had any effect: config/app.php had no timezone key at all, so Laravel's own fallback won — and that fallback is a literal 'UTC' string, not an env() lookup (vendor/laravel/framework/config/app.php). APP_TIMEZONE has therefore been inert since the config was slimmed, despite being shipped in .env.example. inject.sh wrote a bare TIMEZONE key into .env, which nothing reads, so setting the documented container variable also did nothing. It now writes APP_TIMEZONE, and accepts either name so existing compose files keep working without edits. Verified against a built image: TIMEZONE=Europe/Berlin now yields APP_TIMEZONE=Europe/Berlin in .env and config('app.timezone') == Europe/Berlin, where before both spellings left it on UTC. --- config/app.php | 14 ++++++++++++++ docker/production/inject.sh | 9 +++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/config/app.php b/config/app.php index a6532276..c6905ec9 100644 --- a/config/app.php +++ b/config/app.php @@ -4,6 +4,20 @@ use Illuminate\Support\Facades\Facade; return [ + /* + |-------------------------------------------------------------------------- + | Application Timezone + |-------------------------------------------------------------------------- + | + | The default timezone for date and date-time functions. Laravel's own + | fallback is the literal string 'UTC' rather than an env() lookup, so + | without this key APP_TIMEZONE has no effect at all and scheduled tasks + | and recurring invoices always run on UTC. + | + */ + + 'timezone' => env('APP_TIMEZONE', 'UTC'), + /* |-------------------------------------------------------------------------- | Class Aliases diff --git a/docker/production/inject.sh b/docker/production/inject.sh index 3119172e..20658249 100644 --- a/docker/production/inject.sh +++ b/docker/production/inject.sh @@ -48,8 +48,13 @@ elif [ "$DB_PASSWORD_FILE" != '' ]; then value=$(<$DB_PASSWORD_FILE) replace_or_insert "DB_PASSWORD" "$value" fi -if [ "$TIMEZONE" != '' ]; then - replace_or_insert "TIMEZONE" "$TIMEZONE" +# Laravel reads APP_TIMEZONE. This previously wrote a bare TIMEZONE key, which +# nothing consumed, so setting the variable silently did nothing. Accept both +# names so existing compose files keep working. +if [ "$APP_TIMEZONE" != '' ]; then + replace_or_insert "APP_TIMEZONE" "$APP_TIMEZONE" +elif [ "$TIMEZONE" != '' ]; then + replace_or_insert "APP_TIMEZONE" "$TIMEZONE" fi if [ "$CACHE_STORE" != '' ]; then replace_or_insert "CACHE_STORE" "$CACHE_STORE"