FROM rust:latest

# Nightly is required for the float_erf feature used in lib.rs.
# Install the components/targets that rust-toolchain.toml requires so rustup
# doesn't try to add them at runtime (that triggers an overlayfs rename which
# intermittently fails with EXDEV / "Invalid cross-device link").
RUN rustup toolchain install nightly \
        --component rustfmt --component clippy \
        --target wasm32-unknown-unknown \
    && rustup default nightly

# Python runtime
RUN apt-get update && apt-get install -y --no-install-recommends \
    python3 python3-pip python3-venv python3-dev \
    && rm -rf /var/lib/apt/lists/*

# Isolated venv so pip doesn't fight with the system Python
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# Pre-install Python deps as a cached layer
COPY compare/requirements.txt /tmp/requirements.txt
RUN pip install --no-cache-dir -r /tmp/requirements.txt

WORKDIR /workspace
