# Dockerfile

ARG         AWS_ACCOUNT=086679231553

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

WORKDIR     /var/app

USER        root

# Update and install common packages

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

# Add application and install requirements
COPY        requirements.txt ./
RUN         pip install --upgrade pip
RUN         pip install -I -r requirements.txt
ADD         . /var/app


###############################################
### Build image for live deployment  ###
###############################################
FROM base AS deploy

# Remove tests, etc.
RUN         rm -rf /var/app/tests/ /var/app/.flake8

USER        worker
ENTRYPOINT   ["python", "main.py"]


###############################################
### Build image for dev ###
###############################################
FROM base AS deploy

# Remove tests, etc.
RUN         pip install -r requirements-dev.txt

USER        worker
ENTRYPOINT   ["python", "main.py"]


#################################
### Build image for unit-lint ###
#################################
FROM        base AS unit-lint

# Install test requirements
RUN         pip install -r requirements-dev.txt

USER        worker
ENTRYPOINT  ["flake8", "main.py", "src/"]
