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
This commit is contained in:
@@ -23,4 +23,12 @@ 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"]
|
||||
|
||||
Reference in New Issue
Block a user