FROM docker.io/library/debian:{{ uffd_build_debian_version }}-slim
# Disable interactivity for debconf
ENV DEBIAN_FRONTEND=noninteractive
# Configure uwsgi parameters for running uffd as an app in there
ENV UWSGI_DEB_CONFNAMESPACE="app"
ENV UWSGI_DEB_CONFNAME="uffd"
# Prepare the package sources and install needed software
RUN apt-get -qq update && \
    apt-get -qq dist-upgrade && \
    apt-get -qq install ca-certificates
# Place the pacakge sources data in the image to download uffd
COPY cccv-archive-key.asc /etc/apt/trusted.gpg.d/
COPY cccv-archive.list /etc/apt/sources.list.d/
COPY uffd_2.3.1+git20241021T122809-98fe5690_all.deb /tmp/

# Install uffd from (new) package sources
RUN apt-get -qq update && \
    apt-get -qq install --no-install-recommends /tmp/uffd_2.3.1+git20241021T122809-98fe5690_all.deb && \
# Create a "new" config from the inital config without the preset secret key
    cat /etc/uffd/uffd.cfg | grep -v "SECRET_KEY=" > /etc/uffd/uffd.cfg.tmp && \
    mv /etc/uffd/uffd.cfg.tmp /etc/uffd/uffd.cfg && \
# Create the needed paths for the app
    mkdir --parents /var/www/uffd && \
    mkdir -p /run/uwsgi/app/uffd && \
    chown root:uffd /var/www/uffd

COPY entrypoint.sh /entrypoint.sh

USER uffd
USER root

# Uffd application is exposed on port 3031
EXPOSE 3031/tcp
# Statistics are exposed on port 9191
EXPOSE 9191/tcp

CMD bash /entrypoint.sh

LABEL project="https://git.cccv.de/uffd/uffd"
