fix: move cache:warmup to runtime entrypoint, fix POSTGRES_PASSWORD default

cache:warmup at build time fails because .env.local is not available in the
image (gitignored). Moved to entrypoint.sh which runs after volume mounts.
Also added default value for POSTGRES_PASSWORD in docker-compose.yml.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gwadaking
2026-04-01 17:44:05 -04:00
parent 2cef3725e9
commit 7ecb71599d
3 changed files with 21 additions and 7 deletions

View File

@@ -25,14 +25,20 @@ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
WORKDIR /app
# Copie des dépendances en premier (cache Docker)
# Dépendances en premier (cache Docker layer)
COPY backend/composer.json backend/composer.lock ./
RUN composer install --no-dev --optimize-autoloader --no-scripts
# Copie du reste
# Code source
COPY backend/ .
RUN composer dump-autoload --optimize \
&& php bin/console cache:warmup --env=prod
# Autoload uniquement — pas de cache:warmup ici (besoin de .env.local au runtime)
RUN composer dump-autoload --optimize
COPY docker/php/Caddyfile /etc/caddy/Caddyfile
# Entrypoint : warmup au démarrage du conteneur, quand .env.local est monté
COPY docker/php/entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]

8
docker/php/entrypoint.sh Normal file
View File

@@ -0,0 +1,8 @@
#!/bin/sh
set -e
# Warmup du cache Symfony au démarrage (les vars d'env sont disponibles ici)
php bin/console cache:warmup --env=prod --no-debug 2>&1 || true
# Lance FrankenPHP (comportement par défaut de l'image de base)
exec frankenphp run --config /etc/caddy/Caddyfile "$@"