ARG AWS_ACCOUNT=086679231553
FROM ${AWS_ACCOUNT}.dkr.ecr.us-east-1.amazonaws.com/docker-parent-images:python314

USER root

RUN apt-get update -y && apt-get install -y --no-install-recommends make

WORKDIR /app

ENV POETRY_VIRTUALENVS_CREATE=false

RUN pip install --upgrade pip && pip install --no-cache-dir poetry

# Copy lockfile and manifest first for layer caching
COPY pyproject.toml poetry.lock ./

RUN poetry install --no-root --no-cache

# Copy source and test files
COPY aws_testing_utils ./aws_testing_utils
COPY tests ./tests
COPY Makefile .
COPY lint_and_test.sh .

# Ensure script is executable
RUN chmod +x lint_and_test.sh

# Default command
CMD ["./lint_and_test.sh"]
