# Python 3.13 on Debian 13 (trixie)
FROM python:3.13-slim

# System packages GroupDocs.Signature needs on Linux:
#   libicu-dev                  ICU: the .NET runtime cannot start without it
#   libfontconfig1, fontconfig  font discovery for the bundled SkiaSharp library
#   libgdiplus                  stamps, text rendered as an image, PowerPoint and
#                               image files, signature previews
#   ttf-mscorefonts-installer   Times New Roman and Arial for PDF text signatures
# The fonts package lives in Debian's contrib component, asks for a EULA, and
# downloads the fonts over HTTPS (hence ca-certificates).
RUN sed -i '/^Components:/s/main/main contrib/' /etc/apt/sources.list.d/debian.sources \
    && echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true \
        | debconf-set-selections \
    && apt-get update \
    && apt-get install -y --no-install-recommends \
        libicu-dev libfontconfig1 fontconfig libgdiplus \
        ttf-mscorefonts-installer ca-certificates \
    && fc-cache -f \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install Python dependencies
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

# Copy the app and its input document
COPY sign_pdf_with_text.py sample.pdf ./

# Run the app
CMD ["python", "sign_pdf_with_text.py"]
