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

FROM build-deps as build-venv

WORKDIR /app

COPY requirements.txt /app/

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

FROM build-venv as build-base

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

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

ARG VERSION
ARG REVISION
ARG BUILDTIME

LABEL com.datadoghq.tags.service=atlas-um-integration-example
LABEL com.datadoghq.tags.version=${VERSION}
LABEL REVISION=${REVISION}
LABEL BUILDTIME=${BUILDTIME}

ENV DD_SERVICE=atlas-um-integration-example
ENV DD_VERSION=${VERSION}
ENV SENTRY_PROJECT=atlas-um-integration-example
ENV PORT=8000

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

USER ${APP_USER}

COPY . /app

WORKDIR /app

# Make port 8000 available to the world outside this container
EXPOSE 8000

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