diff --git a/Dockerfile b/Dockerfile index 6b48ada..211a68f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,20 @@ # --- Étape de Build --- FROM composer:2.7 AS build + WORKDIR /var/www/html + +ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/ +RUN chmod +x /usr/local/bin/install-php-extensions && \ + install-php-extensions intl zip bcmath pdo_pgsql + COPY . . + RUN composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader # --- Étape Finale (Production) --- FROM dunglas/frankenphp:1.3-php8.4-alpine -# Installation des dépendances système pour Postgres et GD +# On installe les extensions pour le fonctionnement de l'app en prod RUN apk add --no-cache \ libpq-dev \ libpng-dev \ @@ -15,7 +22,6 @@ RUN apk add --no-cache \ freetype-dev \ icu-dev -# Installation des extensions PHP RUN install-php-extensions \ intl \ pdo_pgsql \ @@ -25,16 +31,12 @@ RUN install-php-extensions \ WORKDIR /var/www/html -# Copie des fichiers depuis le build COPY --from=build /var/www/html /var/www/html -# Variables d'environnement pour Laravel -ENV APP_ENV=production -ENV APP_RUNTIME=Laravel\FrankenPHP\Runtime -ENV MAX_REQUESTS=500 - -# Droits d'accès pour le stockage +# Permissions (crucial pour Laravel) RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache -# Commande de démarrage +ENV APP_ENV=production +ENV APP_RUNTIME=Laravel\FrankenPHP\Runtime + CMD ["sh", "-c", "php artisan migrate --force && php artisan storage:link && frankenphp run --config /etc/caddy/Caddyfile"] diff --git a/docker-compose.prod.yml b/docker-compose.prod.yml index b568356..734f974 100644 --- a/docker-compose.prod.yml +++ b/docker-compose.prod.yml @@ -1,8 +1,6 @@ services: starter-api: - build: - context: . - dockerfile: Dockerfile + image: gitea.leonmorival.com/leon-morival/laravel-starter:latest container_name: starter-starter-api-1 restart: unless-stopped depends_on: