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=apple_charts_exits_notifications
LABEL com.datadoghq.tags.version=${VERSION}
LABEL REVISION=${REVISION}
LABEL BUILDTIME=${BUILDTIME}

ENV DD_SERVICE=apple_charts_exits_notifications
ENV DD_VERSION=${VERSION}
ENV SENTRY_PROJECT=apple_charts_exits_notifications

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

USER ${APP_USER}

COPY . /app

WORKDIR /app

# Run application with uWSGI when the container launches
CMD ["/venv/bin/python", "/app/src/index.py"]

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

WORKDIR /app
