File size: 1,162 Bytes
79ea526
 
 
 
 
 
 
 
 
 
64036c6
79ea526
 
64036c6
 
 
 
 
 
 
 
 
 
 
 
79ea526
 
 
64036c6
 
 
 
 
79ea526
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
FROM python:3.12-slim

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

COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

WORKDIR /app

# Install torch with CUDA 12.8 wheels
RUN uv pip install --system \
    --extra-index-url https://download.pytorch.org/whl/cu128 \
    "torch>=2.8.0"

# Install dia2 deps (without dia2 itself — its setuptools config is broken,
# only lists top-level package and misses subpackages like dia2.core)
RUN uv pip install --system \
    "numpy>=2.1.0,<3.0" \
    "transformers>=4.55.3" \
    "safetensors==0.5.3" \
    "huggingface-hub>=0.24.7" \
    "sphn>=0.2.0" \
    "soundfile>=0.12.1" \
    "whisper-timestamped>=1.14.2" \
    fastapi \
    uvicorn

# Clone dia2 source and add to PYTHONPATH (workaround for broken setuptools config)
RUN git clone --depth 1 https://github.com/nari-labs/dia2.git /opt/dia2

ENV PYTHONPATH="/opt/dia2:${PYTHONPATH}"

COPY app.py .

RUN useradd -m -u 1000 user
USER user

ENV HF_HOME=/tmp/hf_cache
ENV TORCH_HOME=/tmp/torch_cache

EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]