FROM python:3.12-slim

RUN apt-get update && \
    apt-get install -y --no-install-recommends pandoc calibre && \
    rm -rf /var/lib/apt/lists/*

RUN mkdir -p /app /output

WORKDIR /app

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

COPY main.py epub_builder.py generate_reference_doc.py /app/
COPY center-v.lua /app/
COPY pagebreak.lua /app/
COPY epub-style.css /app/
RUN python generate_reference_doc.py

# /vault  - mount your markdown source folder here (read-write for flag reset)
# /output - mount your EPUB destination folder here
VOLUME ["/vault", "/output"]

CMD ["python", "-u", "main.py"]
