FROM debian:trixie-slim

LABEL maintainer="Rémi Duraffort <remi.duraffort@linaro.org>"

ENV DEBIAN_FRONTEND noninteractive

RUN echo 'deb http://deb.debian.org/debian trixie-backports main' > /etc/apt/sources.list.d/backports.list && \
    mkdir -p /usr/share/man/man1 /usr/share/man/man7 && \
{%- if adduser_and_group|default(False) %}
    groupadd --system --gid 200 lavaserver && \
    useradd --system --home /var/lib/lava-server/home/ --uid 200 --gid 200 --shell /bin/sh lavaserver && \
{%- endif %}
    apt-get update -q && \
{%- for dep in dependencies %}
{%- if dep["pkgs"] %}
    apt-get install {% if not dep["recommends"] %}--no-install-recommends {% endif %}--yes {% if dep["from"] %}-t {{ dep["from"] }} {% endif %}{{ dep["pkgs"] }} && \{% endif %}
{%- endfor %}
{%- if pip_packages %}
    apt-get install --no-install-recommends --yes python3-pip && \
    python3 -m pip install --break-system-packages {{ pip_packages|join(" ") }} && \
{%- endif %}
    find /usr/lib/python3/dist-packages/ -name '__pycache__' -type d -exec rm -r "{}" + && \
    rm -rf /var/lib/apt/lists/*
