Files
eden/infra/docker/Dockerfile.node
Matheus (Handix) 29430d0d96 feat(documents): renderização real de PDF via Chromium headless
Substitui a geração de PDF simulada (pdf_s3_key/pdf_sha256/pdf_size_bytes
sempre nulos) por Chromium real (Playwright), portado do
chromiumPdfRenderer.js do legado: SSRF impossível por construção
(setContent + bloqueio de toda requisição de rede da página), browser
único reaproveitado com relançamento automático, semáforo de
concorrência + timeout duro.

Infra: MinIO (compose.yaml, primeiro consumidor real do adapter S3) e
instalação condicional do Chromium só na imagem da API
(Dockerfile.node). DocumentsService.createGeneration agora renderiza,
faz upload e persiste hash/tamanho de verdade; novo endpoint de
download GET /v1/documents/generations/:id/pdf.

Verificado ao vivo através do container real: PDF gerado, baixado, e
SHA-256 conferido byte a byte contra o valor persistido no Postgres.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BcWWuKfykGtUweXmHD6cKx
2026-09-04 09:26:31 -03:00

35 lines
1.4 KiB
Docker

# syntax=docker/dockerfile:1
# Shared Dockerfile for Node.js services (API, worker). Parametrized by
# APP_NAME (the workspace package's folder name under apps/) and PORT.
#
# Not yet size-optimized (copies the whole monorepo incl. devDependencies
# into the runtime stage) — deliberate simplification for Fase 1 bootstrap.
# Image-size hardening (pnpm deploy / multi-stage prune) is Fase 10 scope,
# see docs/implementation-plan.md.
FROM node:22-slim AS base
RUN corepack enable
WORKDIR /repo
FROM base AS build
COPY . .
RUN pnpm install --frozen-lockfile
ARG APP_NAME
RUN pnpm turbo run build --filter=@eden/${APP_NAME}...
FROM node:22-slim AS runtime
RUN corepack enable
WORKDIR /repo
COPY --from=build /repo /repo
ENV NODE_ENV=production
ARG APP_NAME
ENV EDEN_APP_NAME=${APP_NAME}
# The API renders PDFs (documents, quote/offer, e-signature certificate)
# via a real headless Chromium (packages/integrations/src/pdf/renderer.ts).
# Playwright's own installer pulls both the browser binary and the OS
# libraries it needs (fonts, libnss, etc.) that node:22-slim doesn't ship.
# Skipped for other services (worker) that don't render PDFs, to keep
# their image lean — matches this Dockerfile's existing "not yet
# size-optimized, simplify for Fase 1" stance above.
RUN if [ "$APP_NAME" = "api" ]; then pnpm --filter @eden/integrations exec playwright install --with-deps chromium; fi
CMD ["sh", "-c", "pnpm --filter @eden/${EDEN_APP_NAME} start"]