# ---------- ETAPA 1: Build ----------
FROM node:20-alpine AS builder

WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci

COPY src/ src/
COPY static/ static/
COPY .eleventy.js ./

RUN npx @11ty/eleventy

# ---------- ETAPA 2: Servir ----------
FROM nginx:alpine

# Configuración personalizada de Nginx
COPY nginx.conf /etc/nginx/conf.d/default.conf

# Copiar el sitio generado
COPY --from=builder /app/_site /usr/share/nginx/html

# Copiar descargas (no pasan por Eleventy)
COPY downloads/ /usr/share/nginx/html/downloads/

EXPOSE 80
