FROM debian:bookworm-slim

ENV DEBIAN_FRONTEND=noninteractive
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium

RUN apt-get update && apt-get install -y --no-install-recommends \
    ca-certificates \
    chromium \
    fontconfig \
    fonts-dejavu-core \
    nodejs \
    npm \
    pandoc \
    python3 \
    wkhtmltopdf \
  && rm -rf /var/lib/apt/lists/*

RUN npm install -g @mermaid-js/mermaid-cli

WORKDIR /opt/markdown-pdf

COPY assets/render_markdown_pdf.sh /opt/markdown-pdf/render_markdown_pdf.sh
COPY assets/preprocess_mermaid.py /opt/markdown-pdf/preprocess_mermaid.py
COPY assets/puppeteer-config.json /opt/markdown-pdf/puppeteer-config.json
COPY assets/pdf.css /opt/markdown-pdf/pdf.css

RUN chmod +x /opt/markdown-pdf/render_markdown_pdf.sh
