FROM debian:stretch-slim

ARG DEBIAN_FRONTEND=noninteractive
RUN echo "deb http://ftp.es.debian.org/debian stretch-backports main" \
        > /etc/apt/sources.list.d/backoprts.list \
    && apt-get update \
    && apt-get install -y --no-install-recommends \
        apache2 \
        libapache2-mod-php \
        phpldapadmin \
        php-xml \
    && 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"

COPY apache.conf /etc/apache2/sites-available/phpldapadmin.conf

RUN a2ensite phpldapadmin \
    && a2dissite 000-default

CMD ["apachectl", "-D", "FOREGROUND"]