- Dockerfile multi-etapa: build con Playwright (sitio, PDF, precompresión) y nginx sin privilegios en 8080 con healthcheck - nginx: CSP sin unsafe-inline, HSTS, nosniff, Referrer-Policy, caché inmutable para assets con hash, gzip_static, página 404 y /salud - scripts: verificar-prohibidas (falla con PLD, Odoo, lavado, CHM, 115/2026 en dist/), verificar-metricas (falla con resultado sin método), comprimir - Lighthouse CI con umbral 95 en móvil y presupuesto de 1.5 MB / 50 KB de JS - GitHub Actions: check, build, verificaciones, PDF, Lighthouse e imagen Docker Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
29 lines
1.1 KiB
Docker
29 lines
1.1 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
# Etapa 1: build con Node y Chromium (Playwright) para generar el sitio, el PDF
|
|
# del currículum y los archivos precomprimidos.
|
|
FROM mcr.microsoft.com/playwright:v1.64.1-noble AS build
|
|
WORKDIR /app
|
|
ENV CI=true PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 ASTRO_TELEMETRY_DISABLED=1
|
|
COPY package.json package-lock.json ./
|
|
RUN npm ci --no-audit --no-fund
|
|
COPY . .
|
|
RUN npm run check \
|
|
&& npm run build \
|
|
&& npm run verificar:prohibidas \
|
|
&& npm run verificar:metricas \
|
|
&& npm run cv:pdf \
|
|
&& node scripts/comprimir.mjs
|
|
|
|
# Etapa 2: nginx sin privilegios sirviendo dist/ en el puerto 8080.
|
|
FROM nginxinc/nginx-unprivileged:1.31-alpine AS runtime
|
|
USER root
|
|
RUN mkdir -p /etc/nginx/snippets \
|
|
&& rm -f /etc/nginx/conf.d/default.conf
|
|
COPY nginx/seguridad.conf /etc/nginx/snippets/seguridad.conf
|
|
COPY nginx/default.conf /etc/nginx/conf.d/default.conf
|
|
COPY --from=build --chown=nginx:nginx /app/dist /usr/share/nginx/html
|
|
USER nginx
|
|
EXPOSE 8080
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
|
|
CMD wget -q -O /dev/null http://127.0.0.1:8080/salud || exit 1
|