85 lines
2.2 KiB
Docker
85 lines
2.2 KiB
Docker
# ============================================================
|
|
# Dockerfile — Production (FrankenPHP)
|
|
# FrankenPHP = serveur web + PHP runtime tout-en-un
|
|
# Remplace PHP-FPM + Nginx en un seul container
|
|
# ============================================================
|
|
|
|
FROM dunglas/frankenphp:php8.3-alpine AS base
|
|
|
|
# Extensions PHP nécessaires pour Laravel
|
|
RUN apk add --no-cache \
|
|
postgresql-dev \
|
|
libpng-dev \
|
|
libjpeg-turbo-dev \
|
|
freetype-dev \
|
|
libzip-dev \
|
|
oniguruma-dev \
|
|
icu-dev \
|
|
curl \
|
|
unzip \
|
|
git \
|
|
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
|
|
&& docker-php-ext-install \
|
|
pdo \
|
|
pdo_pgsql \
|
|
pgsql \
|
|
mbstring \
|
|
zip \
|
|
gd \
|
|
bcmath \
|
|
intl \
|
|
opcache \
|
|
pcntl
|
|
|
|
# Composer
|
|
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
|
|
|
|
# ── Stage Build (Node pour compiler les assets Vite) ────────
|
|
FROM base AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Dépendances PHP (sans dev)
|
|
COPY composer.json composer.lock ./
|
|
RUN composer install \
|
|
--no-interaction \
|
|
--no-dev \
|
|
--prefer-dist \
|
|
--optimize-autoloader \
|
|
--no-scripts
|
|
|
|
# Dépendances Node + build assets
|
|
COPY package.json package-lock.json* ./
|
|
RUN apk add --no-cache nodejs npm \
|
|
&& npm ci --ignore-scripts
|
|
|
|
COPY . .
|
|
|
|
# Génère les assets Vite
|
|
RUN npm run build
|
|
|
|
# Post-scripts Composer
|
|
RUN composer run-script post-autoload-dump || true
|
|
|
|
# ── Stage Final ──────────────────────────────────────────────
|
|
FROM base AS production
|
|
|
|
WORKDIR /app
|
|
|
|
# Copie tout depuis le builder
|
|
COPY --from=builder /app /app
|
|
|
|
# Config PHP optimisée prod
|
|
COPY docker/php.prod.ini /usr/local/etc/php/conf.d/99-prod.ini
|
|
|
|
# Permissions sur storage et bootstrap/cache
|
|
RUN mkdir -p storage/logs storage/framework/cache storage/framework/sessions storage/framework/views bootstrap/cache \
|
|
&& chown -R www-data:www-data storage bootstrap/cache \
|
|
&& chmod -R 775 storage bootstrap/cache
|
|
|
|
# FrankenPHP écoute sur le port 80
|
|
EXPOSE 80
|
|
|
|
# FrankenPHP sert le dossier public/ de Laravel
|
|
CMD ["frankenphp", "php-server", "--root", "/app/public"]
|