26 lines
777 B
Docker
26 lines
777 B
Docker
# ── Stage 1 : Build Vite ─────────────────────────────────────
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
|
|
COPY package.json ./
|
|
RUN npm install --include=dev
|
|
|
|
COPY . .
|
|
|
|
# En prod le frontend est servi par nginx qui proxifie /api → backend
|
|
# VITE_API_URL est laissé vide : le client utilise le chemin relatif /api
|
|
RUN npm run build
|
|
|
|
# ── Stage 2 : Serveur nginx ───────────────────────────────────
|
|
FROM nginx:1.27-alpine AS runtime
|
|
|
|
# SPA + proxy API
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
|
|
# Assets du build Vite
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
|
|
EXPOSE 80
|
|
|
|
CMD ["nginx", "-g", "daemon off;"]
|