From f714ab4fcb68428e2f45a806c51670ef6dba13fc Mon Sep 17 00:00:00 2001 From: Puechberty Arthur Date: Tue, 31 Mar 2026 22:54:43 +0200 Subject: [PATCH] Refactor Docker configuration for development and production environments --- Dockerfile | 34 ++++++++++++++++++++++++++++++++++ docker-compose.yml | 32 ++++++++------------------------ 2 files changed, 42 insertions(+), 24 deletions(-) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..193b26c --- /dev/null +++ b/Dockerfile @@ -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"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 4c9d679..a47d63b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,27 +1,11 @@ services: - blocnote: - image: node:22-alpine - container_name: blocnote - working_dir: /app - volumes: - - .:/app - - node_modules:/app/node_modules - - nextjs_cache:/app/.next + web: + build: . ports: - - "3016:3000" + - "3000:3000" + volumes: + - ./:/app + - /app/node_modules environment: - - NODE_ENV=production - - NEXT_TELEMETRY_DISABLED=1 - - HOSTNAME=0.0.0.0 - command: sh -c "npm ci --include=dev && npm run build && npm start" - restart: unless-stopped - healthcheck: - test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000"] - interval: 30s - timeout: 10s - retries: 3 - start_period: 60s - -volumes: - node_modules: - nextjs_cache: + - NODE_ENV=development + command: npm run dev \ No newline at end of file