# Dockerfile
FROM 086679231553.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:python312 AS base

WORKDIR /var/app

USER root
# Install system packages.
RUN apt-get update \
    && apt-get -y upgrade \
    && rm -rf /var/lib/apt/lists/*

ENV VIRTUAL_ENV=/var/app
RUN python -m venv ${VIRTUAL_ENV}
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

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

FROM base AS lint_and_test

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

COPY lint-and-test.sh docker-compose.yaml .flake8 ./
COPY tests ./tests

RUN chmod +x lint-and-test.sh

USER worker
ENTRYPOINT ["./lint-and-test.sh"]
