FROM debian:bullseye-slim

ARG DEB_FILE
ARG DEB_DEBUG_FILE

ENV DEBIAN_FRONTEND=noninteractive

USER root

RUN apt-get update && apt-get install adduser && apt-get clean

RUN addgroup --gid 10001 --system liquidsoap && \
    adduser --system --disabled-password --disabled-login --uid 10000 \
    --home /usr/share/liquidsoap --ingroup liquidsoap liquidsoap && \
    usermod --append --groups audio liquidsoap

# For ffmpeg with libfdk-aac
RUN apt-get update && apt install -y ca-certificates && \
    echo "deb https://www.deb-multimedia.org bullseye main non-free" >> /etc/apt/sources.list && \
    apt-get update -oAcquire::AllowInsecureRepositories=true && \
    apt-get install -y --allow-unauthenticated deb-multimedia-keyring

COPY $DEB_FILE liquidsoap.deb
COPY $DEB_DEBUG_FILE liquidsoap-debug.deb

RUN apt-get update && \
    apt-get dist-upgrade -y && \
    apt install -y ./liquidsoap.deb ./liquidsoap-debug.deb && \
    apt-get install -y tini && \
    apt-get clean && \
    rm -f ./liquidsoap.deb ./liquidsoap-debug.deb

USER liquidsoap

ENTRYPOINT ["/usr/bin/tini", "--", "/usr/bin/liquidsoap"]
