# When making changes to and/or building fradrive-env locally, 
# please remember to use the full url below as tag for the 
# local image to ensure that the local instead of the upstream 
# image will be used!
# TODO: switch to pinned versions instead of latest!
FROM registry.uniworx.de/fradrive/fradrive/fradrive-env:latest

USER root

# Install uniworx binary
WORKDIR /fradrive-src
# RUN make clean # TODO: to discuss whether to invalidate all caches beforehand
RUN make bin/uniworx

# Runtime dependencies
# TODO: minimize texlive dependencies, switch to basic schemes where possible
RUN apt-get -y install texlive-latex-recommended texlive-latex-extra texlive-luatex texlive-fonts-recommended texlive-fonts-extra texlive-lang-english texlive-lang-german

# TODO: build container (see nix build)

# TODO: remove build dependencies (e.g. nodejs)

RUN mkdir -p /var/lib
RUN groupadd -r uniworx
RUN useradd -r -g uniworx -d /var/lib/uniworx -M uniworx --uid 999
RUN install -d -g uniworx -o uniworx -m 0750 /var/lib/uniworx
RUN mkdir -p /var/log
RUN install -d -g uniworx -o uniworx -m 0755 /var/log/uniworx

USER uniworx

ENTRYPOINT fradrive-entrypoint.sh
EXPOSE 8080/tcp
VOLUME /var/lib/uniworx /var/log
