FROM 483193324480.dkr.ecr.us-east-1.amazonaws.com/python:3.8-slim-builder as build-deps

FROM build-deps as build-venv

WORKDIR /app

COPY requirements/ /app/requirements/

RUN python -m venv /venv \
&& . /venv/bin/activate \
&& pip --no-cache-dir install --upgrade pip setuptools wheel

FROM build-venv as build-base

RUN . /venv/bin/activate \
&& pip --no-cache-dir install --trusted-host pypi.python.org -r requirements/base.pip

FROM 483193324480.dkr.ecr.us-east-1.amazonaws.com/python:3.8-slim-runner as main

ARG VERSION
ARG REVISION
ARG BUILDTIME

LABEL com.datadoghq.tags.service=apollo-update-hot-hits-history
LABEL com.datadoghq.tags.version=${VERSION}
LABEL REVISION=${REVISION}
LABEL BUILDTIME=${BUILDTIME}

ENV ENVIRONMENT=development
ENV DD_SERVICE=apollo-update-hot-hits-history
ENV DD_VERSION=${VERSION}
ENV DD_API_KEY="placeholder"
ENV SENTRY_PROJECT=apollo_update_hot_hits_history

COPY --from=build-base /venv /venv

USER ${APP_USER}

COPY ./entrypoint.sh /app/entrypoint.sh
COPY ./src /app

WORKDIR /app

CMD ["/app/entrypoint.sh"]

FROM build-base as build-dev

RUN . /venv/bin/activate \
&& pip --no-cache-dir install --trusted-host pypi.python.org -r requirements/dev.pip

FROM build-dev as build-test

RUN . /venv/bin/activate \
&& pip --no-cache-dir install --trusted-host pypi.python.org -r requirements/test.pip

COPY . /app
