mirror of
https://github.com/arthur-pbty/portfolio.git
synced 2026-08-01 20:29:43 +02:00
Refactor Docker setup and configuration for development environment
This commit is contained in:
+34
@@ -0,0 +1,34 @@
|
|||||||
|
# === Étape 1 : Build ===
|
||||||
|
FROM node:20-alpine AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copier les fichiers de dépendances pour profiter du cache Docker
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
# Installer uniquement ce qu'il faut pour le build
|
||||||
|
RUN npm ci
|
||||||
|
|
||||||
|
# Copier tout le code
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
# Build Next.js pour la production
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# === Étape 2 : Runner léger ===
|
||||||
|
FROM node:20-alpine AS runner
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copier uniquement ce qui est nécessaire pour la prod
|
||||||
|
COPY --from=builder /app/package*.json ./
|
||||||
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
|
COPY --from=builder /app/.next ./.next
|
||||||
|
COPY --from=builder /app/public ./public
|
||||||
|
|
||||||
|
# Mode production
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
# Lancer le serveur Next.js
|
||||||
|
CMD ["npm", "start"]
|
||||||
+9
-14
@@ -1,17 +1,12 @@
|
|||||||
services:
|
services:
|
||||||
portfolio:
|
web:
|
||||||
image: node:22-alpine
|
build:
|
||||||
working_dir: /app
|
context: .
|
||||||
volumes:
|
|
||||||
- .:/app
|
|
||||||
- node_modules:/app/node_modules
|
|
||||||
ports:
|
ports:
|
||||||
- "3012:3000"
|
- "3000:3000"
|
||||||
|
volumes:
|
||||||
|
- ./:/app # monte ton code pour hot reload
|
||||||
|
- /app/node_modules # préserver les modules installés dans l'image
|
||||||
environment:
|
environment:
|
||||||
- NODE_ENV=production
|
- NODE_ENV=development
|
||||||
- HOSTNAME=0.0.0.0
|
command: npm run dev
|
||||||
command: sh -c "npm install && npm run build && cp -r public .next/standalone/ && cp -r .next/static .next/standalone/.next/static && node .next/standalone/server.js"
|
|
||||||
restart: unless-stopped
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
node_modules:
|
|
||||||
@@ -1,7 +1,14 @@
|
|||||||
import type { NextConfig } from "next";
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
const nextConfig: NextConfig = {
|
||||||
|
// Mode production strict pour React (détecte les erreurs tôt)
|
||||||
|
reactStrictMode: true,
|
||||||
|
|
||||||
|
// Build standalone pour Docker → image finale légère et indépendante
|
||||||
output: "standalone",
|
output: "standalone",
|
||||||
|
|
||||||
|
// Compression des pages côté serveur (gzip/brotli)
|
||||||
|
compress: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
|
|||||||
Reference in New Issue
Block a user