FROM registry.fedoraproject.org/fedora:44

LABEL org.opencontainers.image.title="Tongs Fedora 44 validation harness"
LABEL org.opencontainers.image.description="Disposable headless test environment for issue 27"

COPY installer-verifier.lock /opt/tongs-harness/installer-verifier.lock

# The verifier closure installs first, by hash and as wheels only.  The test
# tools then resolve fresh in a second call that is constrained to the exact
# locked versions, so it fails rather than replace a hash-checked package.
RUN dnf install --assumeyes --setopt=install_weak_deps=False \
        git-core \
        python3 \
        python3-pip \
    && dnf clean all \
    && python3 -m venv /opt/tongs-harness \
    && /opt/tongs-harness/bin/python -I -m pip install --no-cache-dir \
        --disable-pip-version-check \
        --require-hashes \
        --only-binary=:all: \
        -r /opt/tongs-harness/installer-verifier.lock \
    && sed -n 's/^\([A-Za-z0-9][A-Za-z0-9._-]*==[^ ]*\).*/\1/p' \
        /opt/tongs-harness/installer-verifier.lock \
        > /opt/tongs-harness/installer-verifier.constraints \
    && /opt/tongs-harness/bin/python -I -m pip install --no-cache-dir \
        --disable-pip-version-check \
        -c /opt/tongs-harness/installer-verifier.constraints \
        aiosqlite\>=0.20 \
        build\>=1.2 \
        hatch-vcs \
        hatchling \
        httpx\>=0.27 \
        'mcp[cli]==1.29.1' \
        platformdirs\>=4.0 \
        pyperclip\>=1.8 \
        pytest\>=8.0 \
        pytest-asyncio\>=0.24 \
        pyyaml\>=6.0 \
        setuptools\>=68 \
        textual==4.0.0 \
        wheel \
    && /opt/tongs-harness/bin/python -I -c 'import importlib.metadata as m, sys; pins = [line.strip().split("==") for line in open(sys.argv[1])]; bad = [(n, v, m.version(n)) for n, v in pins if m.version(n) != v]; sys.exit(f"installed versions differ from the lock: {bad}" if bad else 0)' \
        /opt/tongs-harness/installer-verifier.constraints \
    && /opt/tongs-harness/bin/python -I -m pip check

COPY probe.py /opt/tongs-harness/probe.py

ENV PATH="/opt/tongs-harness/bin:${PATH}"
ENTRYPOINT ["python", "/opt/tongs-harness/probe.py"]
