mirror of
https://github.com/arthur-pbty/calculatrice.git
synced 2026-06-03 15:07:19 +02:00
Ajout de la configuration Docker pour le développement et la production
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"]
|
||||
+8
-29
@@ -1,32 +1,11 @@
|
||||
services:
|
||||
calculatrice:
|
||||
image: node:20-alpine
|
||||
container_name: calculatrice-prod
|
||||
working_dir: /app
|
||||
volumes:
|
||||
- .:/app
|
||||
- node_modules:/app/node_modules
|
||||
web:
|
||||
build: .
|
||||
ports:
|
||||
- "3014:3000"
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ./:/app
|
||||
- /app/node_modules
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- NEXT_TELEMETRY_DISABLED=1
|
||||
- HOSTNAME=0.0.0.0
|
||||
command: >
|
||||
sh -c "
|
||||
NODE_ENV=development npm ci &&
|
||||
NODE_ENV=production npm run build &&
|
||||
cp -r public .next/standalone/public &&
|
||||
cp -r .next/static .next/standalone/.next/static &&
|
||||
NODE_ENV=production node .next/standalone/server.js
|
||||
"
|
||||
restart: unless-stopped
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000"]
|
||||
interval: 30s
|
||||
timeout: 10s
|
||||
retries: 3
|
||||
start_period: 120s
|
||||
|
||||
volumes:
|
||||
node_modules:
|
||||
- NODE_ENV=development
|
||||
command: npm run dev
|
||||
Reference in New Issue
Block a user