Files
esh-pfi-infrastructure/stacks/dia/dia2-image/Dockerfile
T
vh 3139e81e8a feat(dia): two-instance Dia2 deployment (dia2-1b + dia2-2b)
The devnen wrapper is single-model and ignores the OpenAI model field, so
offering both Dia2 models to asset-engine as real per-request choices means
one fixed-model instance per model. Rework the dia stack to run two services
from a dia2-capable image:
  * dia2-2b (:8200, best quality), dia2-1b (:8202, streaming) — both GPU 0
  * each pins its model via a mounted /opt/docker/conf/dia2-*/config.yaml
Retire the legacy Dia 1.6B service.

New dia2-image/Dockerfile builds local/dia:v2 = upstream devnen wrapper +
the dia2 package (copied into site-packages; its pyproject build backend
yields an empty UNKNOWN wheel under the base's old setuptools) + the three
missing runtime deps (transformers/sphn/whisper-timestamped); torch 2.12 /
numpy 2.2 in the base already satisfy Dia2. Both instances verified
end-to-end (HTTP 200, Ogg/Opus 24 kHz).
2026-05-31 14:41:11 -07:00

32 lines
1.7 KiB
Docker

# 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"