mirror of
https://github.com/arthur-pbty/moon.git
synced 2026-06-27 14:17:33 +02:00
Ajout de Dockerfile pour la construction et l'exécution de l'application Next.js
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"]
|
||||||
+7
-17
@@ -1,21 +1,11 @@
|
|||||||
services:
|
services:
|
||||||
moon:
|
web:
|
||||||
image: node:20-alpine
|
build: .
|
||||||
working_dir: /app
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
ports:
|
||||||
- "3013:3000"
|
- "3000:3000"
|
||||||
environment:
|
|
||||||
NEXT_TELEMETRY_DISABLED: "1"
|
|
||||||
HOSTNAME: 0.0.0.0
|
|
||||||
PORT: "3000"
|
|
||||||
command: >
|
|
||||||
sh -c "npm ci && npm run build && npx next start -H 0.0.0.0 -p 3000"
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/app
|
- ./:/app
|
||||||
- node_modules:/app/node_modules
|
- /app/node_modules
|
||||||
- next_data:/app/.next
|
environment:
|
||||||
|
- NODE_ENV=development
|
||||||
volumes:
|
command: npm run dev
|
||||||
node_modules:
|
|
||||||
next_data:
|
|
||||||
Reference in New Issue
Block a user