mirror of
https://github.com/arthur-pbty/sudoku.git
synced 2026-06-03 23:36:39 +02:00
feat: Configure Docker setup with Dockerfile and update docker-compose.yml for development
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
-7
@@ -1,10 +1,11 @@
|
|||||||
services:
|
services:
|
||||||
sudoku-app:
|
web:
|
||||||
image: node:20-alpine
|
build: .
|
||||||
working_dir: /app
|
ports:
|
||||||
|
- "3000:3000"
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/app
|
- ./:/app
|
||||||
command: sh -c "npm install && npm run build && npm start"
|
- /app/node_modules
|
||||||
ports:
|
environment:
|
||||||
- "3005:3000"
|
- NODE_ENV=development
|
||||||
restart: unless-stopped
|
command: npm run dev
|
||||||
Reference in New Issue
Block a user