# Not using buster because of bug: https://bugs.php.net/bug.php?id=78870
FROM debian:stretch-slim

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        curl \
        ca-certificates \
        gnupg2

# Apache

RUN apt-get install -y --no-install-recommends \
        apache2 \
        libapache2-mod-php \
    && . /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"

RUN a2dissite 000-default

# NodeJs

RUN curl -fsSL https://deb.nodesource.com/setup_14.x | bash - \
    && apt-get install -y --no-install-recommends nodejs

# Hedera

RUN curl -sL https://apt.verdnatura.es/conf/verdnatura.gpg | apt-key add - \
    && echo "deb http://apt.verdnatura.es/ stretch main" \
        > /etc/apt/sources.list.d/vn.list \
    && apt-get update \
    && apt-get install -y --no-install-recommends \
        php-apcu \
        php-image-text \
        php-text-captcha \
        php-zip \
        hedera-web \
        cron

ARG BUILD_ID=unknown
ARG VERSION
ENV VERSION $VERSION
RUN echo $VERSION

RUN apt-get update \
    && apt-get install -y php-vn-lib hedera-web=$VERSION \
    && rm -rf /var/lib/apt/lists/*

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