From 471f43248b0f51e5fb471153000ac18c13c10706 Mon Sep 17 00:00:00 2001 From: hamed <15238-genius.ha@users.noreply.drupalcode.org> Date: Sun, 28 Jun 2026 10:54:38 +0330 Subject: [PATCH] fix(docker): generate minimal .env when absent (repo .env is gitignored) Symfony Dotenv::bootEnv() hard-requires a .env file even in prod. The repo's .env holds dev secrets and is gitignored, so Coolify's clone ships none and the app fatals with 'Unable to read /app/.env'. Write a minimal APP_ENV=prod .env at build if one wasn't copied; all real values still come from the compose environment (clear_env=no), which Dotenv never overwrites. Co-Authored-By: Claude Opus 4.8 --- Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Dockerfile b/Dockerfile index cfa6b133..20a678c6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -61,6 +61,14 @@ COPY . . COPY --from=vendor /app/vendor ./vendor COPY --from=assets /app/public/build ./public/build +# Symfony's Dotenv::bootEnv() hard-requires a .env file to exist, even in prod. +# The repo's .env is gitignored (it holds dev secrets), so Coolify's clone has +# none and the app fatals with "Unable to read /app/.env". Write a minimal prod +# .env if one wasn't copied in — every real value still comes from the compose +# environment (clear_env=no lets it through), and Dotenv never overwrites an +# already-set env var, so this only satisfies the file-existence requirement. +RUN [ -f .env ] || printf 'APP_ENV=prod\nAPP_DEBUG=0\n' > .env + # Container configuration. COPY docker/php/php.ini /usr/local/etc/php/conf.d/zz-app.ini COPY docker/php/zz-pool.conf /usr/local/etc/php-fpm.d/zz-pool.conf