# Dockerfile

ARG         AWS_ACCOUNT=103233932089

FROM        ${AWS_ACCOUNT}.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:python38 AS base

WORKDIR     /var/app

# Update and install common packages
RUN         yum -y update
RUN         yum -y install curl git tar zip

# Create and configure virtualenv and gunicorn
ENV         VIRTUAL_ENV /var/venv
RUN         python3.8 -m venv ${VIRTUAL_ENV}
ENV         PATH "$VIRTUAL_ENV/bin:$PATH"

RUN         pip install --upgrade pip
RUN         pip install gunicorn
RUN         useradd gunicorn -s /bin/false

# Install requirements
COPY         ./requirements.txt ./requirements-dev.txt /var/app/
RUN         pip install --no-cache-dir -I -r /var/app/requirements.txt
RUN         pip install --no-cache-dir -I -r /var/app/requirements-dev.txt

# Add application
COPY         . /var/app

# Enables prints in python to flush to stdout
ENV         PYTHONUNBUFFERED 1

USER        gunicorn

# Start dev server
ENTRYPOINT  ["/var/venv/bin/python"]
CMD         ["dev.py", "2>&1"]
