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 test_fixtures ./test_fixtures
COPY tests ./tests
COPY Makefile .
COPY lint_and_test.sh .
COPY README.md .

# Install the package itself so its console script and pytest plugin (registered
# via the pytest11 entry point) are available to the test run.
RUN poetry install --only-root --no-cache

RUN chmod +x lint_and_test.sh

CMD ["./lint_and_test.sh"]
