# A dockerfile to run document builds with a minimal TeXLive that has only
# the packages needed for the template pre-installed.
FROM python:3.11-slim-bookworm

ARG TEXLIVE_VERSION=2024

RUN apt update \
    && apt install -y --no-install-recommends \
        curl make git fontconfig locales gpg gpg-agent \
        perl perl-modules libgetopt-long-descriptive-perl libdigest-perl-md5-perl \
    && rm -rf /var/lib/apt/lists/* \
    && rm -rf /var/cache/apt/ \
	&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8


ENV LANG=en_US.utf8 \
    PATH="/opt/texlive/${TEXLIVE_VERSION}/bin/x86_64-linux:$PATH" \
    TEXLIVE_INSTALL_NO_CONTEXT_CACHE=1 \
    NOPERLDOC=1


ADD tex-packages.txt /tmp/

RUN python -m pip install ruamel.yaml install-texlive \
    && python -m install_texlive \
        -p /opt/texlive \
        -t ${TEXLIVE_VERSION} \
        --collections='-a' \
        --package-file /tmp/tex-packages.txt \
        --update \
    && rm -rf /tmp/texlive-${TEXLIVE_VERSION} /tmp/tex-packages.txt

ENTRYPOINT bash
