# This image is used as base image for E2E test images in webstatus and pictory

ARG SRC_ARCH=arm64
ARG DEBIAN_RELEASE=bullseye
ARG SOURCE_IMAGE=registry.gitlab.com/revolutionpi/infrastructure/docker-images/build-container/build-container-${DEBIAN_RELEASE}:${SRC_ARCH}-latest

FROM ${SOURCE_IMAGE} as builder

RUN apt-get update \
	&& apt-get dist-upgrade -y \
	&& apt-get -y install \
	revpi-webstatus \
	revpi-webstatus-redirect \
	pictory

RUN /usr/sbin/revpi-cert-wizard

COPY login.json /var/www/revpi/data
COPY docker-php-entrypoint /usr/local/bin/
COPY apache2-foreground /usr/local/bin/

ENTRYPOINT ["docker-php-entrypoint"]

WORKDIR /var/www/html

FROM builder

ARG ARCH
ARG COMMIT_SHA

LABEL org.opencontainers.image.title="revolutionpi/webstatus/webstatus-development-${DEBIAN_RELEASE}"
LABEL org.opencontainers.image.version="${ARCH}-latest"
LABEL org.opencontainers.image.description="Docker image for local development and testing of webstatus and pictory"
LABEL org.opencontainers.image.source="https://gitlab.com/revolutionpi/webstatus"
LABEL org.opencontainers.image.revision=$COMMIT_SHA
LABEL org.opencontainers.image.arch=$ARCH
LABEL org.opencontainers.image.os=$DEBIAN_RELEASE
LABEL org.opencontainers.image.base.name=${SOURCE_IMAGE}

EXPOSE 80
EXPOSE 41080

EXPOSE 443
EXPOSE 41443

CMD ["apache2-foreground"]
