FROM debian:latest
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update -q \
    && apt-get install -qy build-essential wget libfontconfig1 rsync \
    && rm -rf /var/lib/apt/lists/*

# Install TexLive with scheme-basic
RUN wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz; \
    mkdir /install-tl-unx; \
    tar -xvf install-tl-unx.tar.gz -C /install-tl-unx --strip-components=1; \
    echo "selected_scheme scheme-basic" >> /install-tl-unx/texlive.profile; \
    /install-tl-unx/install-tl -profile /install-tl-unx/texlive.profile; \
    rm -r /install-tl-unx; \
    rm install-tl-unx.tar.gz

ENV PATH="/usr/local/texlive/2024/bin/x86_64-linux:${PATH}"
RUN . /etc/profile

WORKDIR /data

# Install latex packages
RUN tlmgr install latexmk babel-french csquotes xcolor titlesec lastpage hypdoc

VOLUME ["/data"]
COPY source ./source
COPY install ./install
RUN cd install; ./unix.sh