From ae3110cfb1388401193019497236a63372573755 Mon Sep 17 00:00:00 2001 From: Timikana <> Date: Sun, 26 Apr 2026 17:03:38 +0200 Subject: [PATCH] fix(init): strip trailing newline when writing DB_CONNECTION to s6 container env The init script used "echo" to write the DB_CONNECTION value to /run/s6/container_environment/DB_CONNECTION. Since echo appends a newline, the file contains "sqlite\n" instead of "sqlite". s6-overlay reads this file as the env value for child processes, including PHP-FPM. Laravel config caching ("artisan optimize") then captures DB_CONNECTION="sqlite\n" and persists it. At request time Laravel attempts to resolve a connection named "sqlite\n", which does not exist in config("database.connections"), and throws: InvalidArgumentException: Database connection [sqlite ] not configured. Replacing echo with printf "%s" produces a clean value (no trailing newline) and resolves the issue. Reproduces with: docker compose up -d using DB_CONNECTION sqlite (default) Login attempt at /admin/login -> 500 Stack trace shows DatabaseManager throwing on "[sqlite\n]" --- root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run b/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run index c9d50c6..acb08fe 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run +++ b/root/etc/s6-overlay/s6-rc.d/init-speedtest-tracker-config/run @@ -21,7 +21,7 @@ if [[ "${DB_CONNECTION:=sqlite}" = "sqlite" ]]; then lsiown abc:abc /app/www/database/database.sqlite fi export DB_CONNECTION=sqlite - echo "sqlite" > /run/s6/container_environment/DB_CONNECTION + printf "%s" "sqlite" > /run/s6/container_environment/DB_CONNECTION elif [[ "${DB_CONNECTION}" = "mysql" ]]; then echo "Waiting for DB to be available" END=$((SECONDS + 30))