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

WORKDIR /var/app
# Set service user
USER worker

# Create and configure virtualenv and worker
RUN python3.12 -m venv ./venv
RUN chown -R worker /var/app
RUN ./venv/bin/python -m pip install --upgrade pip
ENV PATH "/var/app/venv/bin:$PATH"

FROM base AS deploy

# Add application and install requirements
COPY requirements.txt ./
RUN ./venv/bin/pip install -I -r requirements.txt

COPY index.py logger.py config.py ./

ENTRYPOINT ["/var/app/venv/bin/python", "index.py"]

FROM base AS unit-lint

COPY requirements.txt requirements-dev.txt ./
RUN pip install --upgrade pip && \
    pip install -r requirements.txt && \
    pip install -r requirements-dev.txt

COPY config.py index.py logger.py lint-and-test.sh docker-compose.yaml .flake8 ./
COPY tests/ ./tests

ENTRYPOINT ["/var/app/lint-and-test.sh"]
