# The test agent image (docs/design/agent-isolation.md §8): the agent image plus flyloft from the working tree, to run
# scripted turns. Build from the repository root with --build-arg AGENT_IMAGE=<the agent image's tag>.
ARG AGENT_IMAGE
FROM ${AGENT_IMAGE}
RUN apt-get update && apt-get install -y --no-install-recommends python3-venv && rm -rf /var/lib/apt/lists/*
# Dependencies first, against an empty package, so a source change only redoes the --no-deps install below.
# hatch-vcs reads the version from git, and the build context has no repository.
COPY pyproject.toml README.md /opt/flyloft-src/
RUN mkdir -p /opt/flyloft-src/src/flyloft && touch /opt/flyloft-src/src/flyloft/__init__.py \
    && python3 -m venv /opt/flyloft \
    && SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0 /opt/flyloft/bin/pip install --no-cache-dir "/opt/flyloft-src[server]"
COPY src /opt/flyloft-src/src
RUN SETUPTOOLS_SCM_PRETEND_VERSION=0.0.0 /opt/flyloft/bin/pip install --no-cache-dir --no-deps --force-reinstall /opt/flyloft-src
# Scripted turns import tests.scripts only.
COPY tests/__init__.py /opt/flyloft-src/tests/__init__.py
COPY tests/scripts /opt/flyloft-src/tests/scripts
ENV PATH=/opt/flyloft/bin:$PATH
