# pi coding agent 1.7.0 + Basalt (jesdga95/basalt, branch qwen4-35b @ 4dbca9ce, qwen4exp), one RTX 5090. The same Dockerfile in
# pi17-basalt-qwen4-35b-a3b-nvfp4-5090 and pi17-basalt-qwen38fn-iq3s-5090: Basalt's qwen4exp architecture serves both
# Qwen4-35B-A3B and Qwen3.8-Flash-Next, so the two capsules share one engine build.
# Base: nvidia/cuda:13.1.1-devel-ubuntu24.04, pinned by digest (the pack author's CUDA 13.1).
FROM node@sha256:48e4b67d85f87bd551df43704e24d252f56cc5f8e9718841aace50f19948f0f9 AS node

FROM nvidia/cuda@sha256:9cf8694a27722418a1f175d90f85d5afb5a728fd4a9907d7f0565efecfa14d32

RUN apt-get update -qq && apt-get install -y --no-install-recommends \
      build-essential cmake git curl ca-certificates python3 python3-venv \
      ripgrep jq procps less file unzip xz-utils \
    && rm -rf /var/lib/apt/lists/*

# Basalt main at fe03cb21 (0.7.0 before its release: the official Qwen4-35B-A3B pack, Qwen's own chat encoder, DFlash 2),
# its server venv from the commit's requirements.txt. The build has no GPU: it compiles for sm_120 without a device.
WORKDIR /opt/basalt
RUN git init -q . \
    && git fetch -q --depth 1 https://github.com/jesdga95/basalt fe03cb21aaf96c4ed46684454df28c2c30f1b3d6 \
    && git checkout -q FETCH_HEAD \
    && test "$(git rev-parse HEAD)" = fe03cb21aaf96c4ed46684454df28c2c30f1b3d6 \
    && cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DBASALT_MODELS=qwen4exp \
    && cmake --build build -j"$(nproc)" \
    && python3 -m venv .venv && .venv/bin/pip install --no-cache-dir -r requirements.txt
ENV PATH=/opt/basalt/bin:$PATH

# Node 22.23.2 from node:22-bookworm-slim, then pi 1.7.0.
COPY --from=node /usr/local/bin/node /usr/local/bin/node
COPY --from=node /usr/local/lib/node_modules /usr/local/lib/node_modules
RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \
    && ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \
    && npm install -g --ignore-scripts @earendil-works/pi-coding-agent@1.7.0 && npm cache clean --force
ENV PI_OFFLINE=1 PI_TELEMETRY=0

# Gateway deps (opencode-basalt-5090's pins, Python 3.12).
RUN python3 -m venv /opt/gateway && /opt/gateway/bin/pip install --no-cache-dir \
      fastapi==0.115.14 uvicorn==0.32.1 httpx==0.28.1 \
      starlette==0.46.2 pydantic==2.14.1 pydantic_core==2.50.1 annotated-types==0.8.0 \
      typing_extensions==4.16.0 typing-inspection==0.4.4 anyio==4.15.1 idna==3.20 \
      certifi==2026.10.23 httpcore==1.0.9 h11==0.16.0 click==8.5.0
