# dia2-capable image, layered on the upstream devnen wrapper image
# (local/dia:<base>, which ships the wrapper + the dia1 package only).
#
# Why this exists: the upstream image does NOT bundle the dia2 package or
# its runtime deps. The wrapper tries to `git clone nari-labs/dia2 &&
# pip install` it at RUNTIME on first Dia2 load — which fails (no `git`,
# and would be lost on recreate). We provision Dia2 at build time instead.
#
# Two upstream packaging quirks, both handled below:
#   1. dia2's pyproject build backend yields an empty "UNKNOWN" wheel under
#      the base image's old setuptools (59.6 < the required 70) and rejects
#      editable installs. dia2 is pure-python (packages=["dia2"]), so we
#      copy the package straight into site-packages — the wrapper only needs
#      `from dia2 import ...` to succeed, not pip-tracked metadata.
#   2. A bare `pip install dia2_src` would also drag torch>=2.8 + pin
#      safetensors==0.5.3. The base ALREADY satisfies dia2 (torch 2.12,
#      numpy 2.2, safetensors 0.7) — so we install ONLY the genuinely
#      missing runtime deps and leave the heavy/pinned stack untouched.
#      (transformers/sphn/whisper-timestamped verified as the minimal set
#      that makes the wrapper's `from dia2 import Dia2, ...` import succeed.)
ARG DIA_BASE=local/dia:v1
FROM ${DIA_BASE}

RUN apt-get update \
    && apt-get install -y --no-install-recommends git \
    && rm -rf /var/lib/apt/lists/*

RUN git clone --depth 1 https://github.com/nari-labs/dia2.git /opt/dia2_src \
    && cp -r /opt/dia2_src/dia2 "$(python3 -c 'import site; print(site.getsitepackages()[0])')/" \
    && rm -rf /opt/dia2_src \
    && pip install --no-cache-dir "transformers>=4.55.3" "sphn>=0.2.0" "whisper-timestamped>=1.14.2"
