# ===================================================================== # Zenón Pereyra · sitio estático servido con nginx # --------------------------------------------------------------------- # Build en 2 etapas: la primera compila el sitio con Node, la segunda # copia solo el dist/ a una imagen nginx:alpine liviana. # Resultado: ~25 MB de imagen, sin node_modules en producción. # ===================================================================== # ---------- Etapa 1: build ---------- FROM node:22-alpine AS builder WORKDIR /build # Copiar manifests primero (mejor cache de Docker). # Ojo: el package.json vive en sitio/ (no en la raíz del contexto). COPY sitio/package.json sitio/package-lock.json* ./ # Instalar dependencias RUN npm ci --no-audit --no-fund || npm install --no-audit --no-fund # Copiar el resto del proyecto Astro COPY sitio/ ./ # Build de producción (genera dist/) RUN npm run build # ---------- Etapa 2: runtime ---------- FROM nginx:1.27-alpine # Configuración de nginx optimizada COPY deploy/nginx.conf /etc/nginx/nginx.conf # Copiar el sitio compilado COPY --from=builder /build/dist /usr/share/nginx/html # Salud: nginx responde 200 en / HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD wget -qO- http://localhost:80/ >/dev/null 2>&1 || exit 1 EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]