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 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user