FROM debian:bookworm-slim

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        apache2 \
        reprepro \
        openssh-server \
    && rm -rf /var/lib/apt/lists/* \
    && . /etc/apache2/envvars \
    && ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log" \
    && ln -sfT /dev/stdout "$APACHE_LOG_DIR/access.log" \
    && ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log"

WORKDIR /var/lib/reprepro
EXPOSE 80

RUN groupadd -g 600 reprepro \
    && useradd -d /var/lib/reprepro -u 600 -g 600 -m -s /bin/bash reprepro

COPY apache-conf.conf /etc/apache2/conf-available/reprepro.conf
COPY apache-site.conf /etc/apache2/sites-available/reprepro.conf

RUN a2enconf reprepro \
    && a2ensite reprepro \
    && a2dissite 000-default

COPY entrypoint.sh /

ENTRYPOINT [ "/entrypoint.sh" ]
CMD ["apachectl", "-D", "FOREGROUND"]
