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


RUN apt-get update && apt-get install -y \
    build-essential \
    && rm -rf /var/lib/apt/lists/*


WORKDIR /app


# NOTE (v1.1): the `>=` specifiers are quoted — unquoted they were shell
# redirections that littered /app with junk files (`=8.0`, …), which would
# pollute model.patch capture. Same packages/constraints as before.
RUN pip install --no-cache-dir \
    aioconsole==0.8.1 \
    aiohttp==3.10.10 \
    aiotools==1.7.0 \
    attrs==24.2.0 \
    build==1.2.2.post1 \
    'click>=8.0' \
    docutils==0.21.2 \
    ipdb==0.13.13 \
    'janus>=1.0' \
    'jinja2>=3.1.2' \
    mypy==1.13.0 \
    pre-commit==3.5.0 \
    'prompt_toolkit>=3.0' \
    pytest==8.3.3 \
    pytest-asyncio==0.24.0 \
    pytest-aiohttp==1.0.5 \
    pytest-cov==4.0.0 \
    pytest-sugar==0.9.7 \
    ruff==0.7.2 \
    telnetlib3==2.0.4 \
    terminaltables==3.1.10 \
    towncrier==24.8.0 \
    'trafaret>=2.1.1' \
    types-requests \
    'typing-extensions>=4.1' \
    uvloop==0.21.0


# 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=b73fea2e0682803bda7531c93cd1dfb360839175
RUN git clone https://github.com/aio-libs/aiomonitor . \
 && 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)


ENV SETUPTOOLS_SCM_PRETEND_VERSION=0.7.1


RUN pip install -e .

# v1.1 node-id scoring uses pytest's native --junitxml (already pinned above);
# no extra reporter dep. The worktree must stay porcelain-clean for model.patch.
RUN test -z "$(git status --porcelain)"


ENV PYTHONUNBUFFERED=1


# Disable git commit hooks (husky etc.): dev-workflow tooling, not task content.
# Broken hook environments otherwise block the agent's (and oracle's) commits.
RUN cd /app && git config core.hooksPath /dev/null

CMD ["/bin/bash"]
