# This image is used for E2E tests in webstatus and pictory

FROM registry.gitlab.com/revolutionpi/webstatus/webstatus-development-bullseye:arm64-latest as builder

# Use login shell to support .bashrc and .nvm
SHELL ["/bin/bash","--login", "-c"]

RUN apt-get update \
	&& apt-get dist-upgrade -y \
	&& apt-get -y install \
	python3-revpimodio2 \
	chromium

# Use nvm to install nodejs v18 on bullseye
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
RUN nvm install v18

WORKDIR /opt/testcafe

COPY docker-entrypoint.sh .
COPY docker-entrypoint-ci.sh .
COPY package.json .
COPY package-lock.json .

RUN npm ci --omit dev

FROM builder

ARG ARCH
ARG COMMIT_SHA

LABEL org.opencontainers.image.title="revolutionpi/webstatus/webstatus-testcafe-${DEBIAN_RELEASE}"
LABEL org.opencontainers.image.version="${ARCH}-latest"
LABEL org.opencontainers.image.description="Docker image for running Testcafe E2E tests against 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}

WORKDIR /opt/testcafe
COPY tests/ tests/

EXPOSE 80
EXPOSE 41080

EXPOSE 443
EXPOSE 41443

# Overwrite apache2 entrypoint from base image
ENTRYPOINT [""]

