# Dockerfile

ARG         AWS_ACCOUNT=086679231553

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

WORKDIR     /var/app

USER        root

# Update and install common packages
RUN         apt-get update && apt-get upgrade -y
RUN         apt-get -y install zip libffi-dev gcc

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

RUN         python -m pip install --upgrade pip setuptools

COPY        requirements.txt ./
RUN         pip install -I -r /var/app/requirements.txt
ADD         . /var/app

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

USER        root

# Add startup script
RUN         apt-get -y install uwsgi
RUN         useradd uwsgi -s /bin/false
ADD         uwsgi-start.sh /
RUN         chmod +x /uwsgi-start.sh

ENTRYPOINT  ["/uwsgi-start.sh"]

EXPOSE      8080


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

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

# Copy files required to run linting and unit tests
COPY        scripts/unit-lint.sh ./scripts/unit-lint.sh

ENTRYPOINT  ["scripts/unit-lint.sh"]


########################################
### Build image for integration-test ###
########################################
FROM        base AS integration-test

# Copy files required to run linting and unit tests
COPY        tests ./tests
COPY        scripts/integration.sh ./scripts/integration.sh

# Install test requirements
RUN         python3.13 -m venv tests/integration/env
RUN         pip3 install -r tests/integration/requirements.txt

ENTRYPOINT  ["scripts/integration.sh"]
