FROM public.ecr.aws/x8v8d7g8/mars-base:latest
WORKDIR /app

# Git time-travel: clone, then make the repo's default branch point AT the base
# commit with no future history — a real branch checkout (not a detached HEAD),
# future commits/tags gc'd away so the reference solution can't leak from history.
ARG BASE_SHA=11614be9021aa4ac078d4d0693a8b5250a1010d8
RUN git clone https://github.com/fastapi/fastapi . \
 && DEFAULT="$(git remote show origin | sed -n 's/.*HEAD branch: //p')" \
 && git checkout -B "$DEFAULT" "$BASE_SHA" \
 && git remote remove origin \
 && for b in $(git for-each-ref --format='%(refname:short)' refs/heads | grep -vx "$DEFAULT"); do git branch -D "$b" || true; done \
 && for t in $(git tag); do git merge-base --is-ancestor "$t" HEAD 2>/dev/null || git tag -d "$t"; done \
 && git reflog expire --expire=now --all \
 && git gc --prune=now \
 && (git submodule update --init --recursive || true)

RUN pip install --no-cache-dir -e ".[all]" \
    && pip install --no-cache-dir \
        "pytest>=9.0.0" \
        "pytest-timeout>=2.4.0" \
        "pytest-xdist[psutil]>=2.5.0" \
        "pytest-cov>=4.0.0" \
        "pytest-sugar>=1.0.0" \
        "anyio[trio]>=3.2.1" \
        "httpx>=0.23.0" \
        "inline-snapshot[black]>=0.21.1" \
        "dirty-equals>=0.9.0" \
        "orjson>=3.9.3" \
        "ujson>=5.8.0" \
        "python-multipart>=0.0.18" \
        "sqlmodel>=0.0.31" \
        "flask>=3.0.0" \
        "pyjwt>=2.9.0" \
        "pwdlib[argon2]>=0.2.1" \
        "a2wsgi>=1.9.0" \
        "pyyaml>=5.3.1" \
        "strawberry-graphql>=0.200.0,<1.0.0" \
        coverage \
        sqlalchemy

# Dependency-drift pin: starlette >=1.0.1 (late May 2026) deprecates using
# `httpx` with starlette.testclient (wants `httpx2`); fastapi's pytest config
# (`filterwarnings = error`) turns that warning into collection errors across
# the entire suite. 1.0.0 is the era-appropriate release for this base commit.
RUN pip install --no-cache-dir "starlette==1.0.0"

# v1.1 node-id scoring: pytest ships a native JUnit XML reporter (--junitxml),
# so no extra reporter dependency is required.

CMD ["bash"]
