60 lines
1.2 KiB
Docker
60 lines
1.2 KiB
Docker
# ── Stage 1 : build des assets frontend ─────────────────────────────────────
|
|
FROM node:22-alpine AS frontend
|
|
|
|
WORKDIR /app
|
|
|
|
COPY package.json package-lock.json* ./
|
|
RUN npm ci --ignore-scripts
|
|
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
|
|
# ── Stage 2 : image de production PHP/FrankenPHP ─────────────────────────────
|
|
FROM dunglas/frankenphp:php8.4-alpine
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
RUN install-php-extensions \
|
|
pdo_pgsql \
|
|
opcache \
|
|
pcntl \
|
|
zip \
|
|
intl
|
|
|
|
|
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
|
|
|
|
|
COPY composer.json composer.lock ./
|
|
|
|
RUN composer install \
|
|
--no-dev \
|
|
--no-interaction \
|
|
--prefer-dist \
|
|
--optimize-autoloader \
|
|
--no-scripts
|
|
|
|
|
|
COPY . .
|
|
|
|
# Écrase public/build avec les assets compilés par le stage frontend
|
|
COPY --from=frontend /app/public/build ./public/build
|
|
|
|
|
|
RUN composer dump-autoload --optimize
|
|
|
|
|
|
RUN php artisan config:cache
|
|
RUN php artisan route:cache
|
|
RUN php artisan view:cache
|
|
|
|
|
|
RUN chown -R www-data:www-data storage bootstrap/cache
|
|
|
|
|
|
EXPOSE 8000
|
|
|
|
CMD ["frankenphp", "php-server", "--listen", "0.0.0.0:8000"]
|