36 lines
795 B
Docker
36 lines
795 B
Docker
# ---- Build stage ----
|
|
FROM node:20-alpine AS builder
|
|
|
|
# Installer pnpm
|
|
RUN npm install -g pnpm
|
|
|
|
# Créer le répertoire de travail
|
|
WORKDIR /app
|
|
|
|
# Copier uniquement les fichiers nécessaires pour les dépendances
|
|
COPY package.json pnpm-lock.yaml ./
|
|
|
|
# Installer les dépendances
|
|
RUN pnpm install --frozen-lockfile
|
|
|
|
# Copier le reste du code
|
|
COPY . .
|
|
|
|
# Build du frontend
|
|
RUN pnpm build
|
|
|
|
# ---- Production stage ----
|
|
FROM nginx:alpine AS runner
|
|
|
|
# Supprimer la config par défaut de nginx
|
|
RUN rm -rf /usr/share/nginx/html/*
|
|
|
|
# Copier les fichiers générés par Vite
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
# Copier une config nginx custom (optionnel, sinon il sert juste les fichiers)
|
|
# COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["nginx", "-g", "daemon off;"] |