feat(deploy): Dockerfiles de production + compose + guide Coolify
- frontend/Dockerfile.prod : Next.js standalone (294 Mo), régénère les assets DSFR, injecte NEXT_PUBLIC_API_URL au build (npm ci --ignore-scripts pour le postinstall) - backend/Dockerfile.prod + docker/entrypoint.sh : API Laravel, migrations + seed idempotent + serveur, génération de secrets en fallback - docker-compose.prod.yml : Postgres + API + Front pour déploiement Coolify - next.config.ts : output standalone ; .dockerignore back/front - DEPLOIEMENT_COOLIFY.md : guide + variables d'environnement Images de prod testées (build + smoke-test DSFR OK). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+10
-1
@@ -1,3 +1,12 @@
|
||||
node_modules
|
||||
.next
|
||||
.env.local
|
||||
out
|
||||
build
|
||||
public/dsfr
|
||||
.git
|
||||
.gitignore
|
||||
npm-debug.log*
|
||||
.env*
|
||||
Dockerfile*
|
||||
.dockerignore
|
||||
coverage
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
# Image de production du frontend Next.js (CESIZen) — sortie "standalone".
|
||||
|
||||
# ─── Étape build ───────────────────────────────────────────────
|
||||
FROM node:20-alpine AS builder
|
||||
WORKDIR /app
|
||||
|
||||
# Dépendances. On ignore les scripts ici : le postinstall (copy-dsfr) a besoin
|
||||
# de scripts/copy-dsfr.mjs, qui n'est copié qu'avec le code source plus bas.
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci --ignore-scripts
|
||||
|
||||
# Code source
|
||||
COPY . .
|
||||
|
||||
# Génère les assets DSFR dans public/dsfr (hors git) depuis node_modules
|
||||
RUN node scripts/copy-dsfr.mjs
|
||||
|
||||
# L'URL publique de l'API est injectée AU BUILD (variables NEXT_PUBLIC_*)
|
||||
ARG NEXT_PUBLIC_API_URL
|
||||
ENV NEXT_PUBLIC_API_URL=$NEXT_PUBLIC_API_URL
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# ─── Étape runtime ─────────────────────────────────────────────
|
||||
FROM node:20-alpine AS runner
|
||||
WORKDIR /app
|
||||
ENV NODE_ENV=production
|
||||
ENV NEXT_TELEMETRY_DISABLED=1
|
||||
ENV PORT=3000
|
||||
ENV HOSTNAME=0.0.0.0
|
||||
|
||||
# Assets statiques (dont public/dsfr) + sortie standalone
|
||||
COPY --from=builder /app/public ./public
|
||||
COPY --from=builder /app/.next/standalone ./
|
||||
COPY --from=builder /app/.next/static ./.next/static
|
||||
|
||||
EXPOSE 3000
|
||||
CMD ["node", "server.js"]
|
||||
@@ -1,7 +1,8 @@
|
||||
import type { NextConfig } from "next";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
/* config options here */
|
||||
// Sortie autonome pour une image Docker de production légère.
|
||||
output: "standalone",
|
||||
};
|
||||
|
||||
export default nextConfig;
|
||||
|
||||
Reference in New Issue
Block a user