# --- Stage 1: build del sitio estático con MkDocs Material ---
FROM python:3.12-slim AS build

WORKDIR /site

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY mkdocs.yml .
COPY docs/ docs/

# --strict: cualquier link roto o warning de nav rompe el build,
# para no publicar nunca un sitio con referencias muertas.
RUN mkdocs build --strict

# --- Stage 2: sirve el sitio estático generado con nginx ---
FROM nginx:1.27-alpine

# libssl3/libcrypto3 de la base nginx:1.27-alpine traen un CVE CRITICAL
# con fix ya publicado por Alpine (CVE-2026-31789, heap buffer overflow
# en OpenSSL) -- detectado por el gate de Trivy imagen del pipeline
# (run 144). Solo se actualizan estos dos paquetes puntuales.
RUN apk update \
    && apk upgrade --no-cache libssl3 libcrypto3 \
    && rm -rf /var/cache/apk/*

COPY --from=build /site/site /usr/share/nginx/html

EXPOSE 80
