17 lines
550 B
Docker
17 lines
550 B
Docker
# ── Fase 1: Compilació amb Node.js ────────
|
|
FROM node:20-alpine AS builder
|
|
WORKDIR /app
|
|
# Instal·la dependències primer (aprofita la cache de Docker)
|
|
COPY package*.json ./
|
|
RUN npm ci
|
|
# Copia el codi font i compila
|
|
COPY . .
|
|
RUN npm run build
|
|
|
|
# ── Fase 2: Servir amb Nginx (imatge mínima) ──
|
|
FROM nginx:alpine
|
|
# Copia NOMÉS la carpeta dist/ de la fase anterior
|
|
COPY --from=builder /app/dist /usr/share/nginx/html
|
|
# Configuració Nginx per a SPA i rutes d'Astro
|
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
|
EXPOSE 80 |