UDface11jkj commited on
Commit
d9a76ba
Β·
verified Β·
1 Parent(s): ca46f93

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +16 -46
Dockerfile CHANGED
@@ -1,59 +1,29 @@
1
- # ─────────────────────────────────────────────────────────────
2
- # Dockerfile.cpu.fastapi β€” CPU-only FastAPI deployment for Dia
3
- # Build: docker build . -f Dockerfile.cpu.fastapi -t dia-cpu-fastapi
4
- # Run: docker run --rm -p 7860:7860 dia-cpu-fastapi
5
- # ─────────────────────────────────────────────────────────────
6
-
7
- # 1) Base image
8
  FROM python:3.10-slim
9
 
10
- # 2) Non-interactive apt
11
- ENV DEBIAN_FRONTEND=noninteractive
 
 
12
 
13
- # 3) System dependencies
14
- RUN apt-get update && \
15
- apt-get install -y --no-install-recommends \
16
- libsndfile1 \
17
- ffmpeg \
18
- curl \
19
- git \
20
  && rm -rf /var/lib/apt/lists/*
21
 
22
- # 4) Set workdir
23
  WORKDIR /app
24
 
25
- # 5) Copy and install Python deps
26
- COPY requirements.txt ./
27
- RUN pip install --upgrade pip && \
28
- # CPU-only PyTorch wheels
29
- pip install torch torchaudio --index-url https://download.pytorch.org/whl/cpu && \
30
- # The rest of your libs (including descript-audio-codec, fastapi, uvicorn, etc.)
31
- pip install --no-cache-dir -r requirements.txt
32
-
33
- # 6) Pre-download DAC + Dia model weights into a shared cache
34
- RUN mkdir -p /app/.cache/huggingface /app/models/dac && \
35
- chmod -R 777 /app/.cache /app/models/dac && \
36
- # 6a) Download DAC codebook
37
- python -m dac download && \
38
- # 6b) Download Dia backbone
39
- python - <<EOF
40
- from huggingface_hub import snapshot_download
41
- snapshot_download(repo_id="nari-labs/Dia-1.6B", cache_dir="/app/.cache/huggingface")
42
- EOF
43
 
44
- # 7) Copy your FastAPI app
45
  COPY . .
46
 
47
- # 8) Env vars so Dia & HF hub pick up the right cache
48
- ENV HF_HOME=/app/.cache/huggingface
49
- ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
50
- ENV XDG_CACHE_HOME=/app/.cache/huggingface
51
- ENV DIA_DAC_PATH=/app/models/dac
52
-
53
- # 9) Expose Uvicorn port
54
  EXPOSE 7860
55
 
56
- # 10) Launch FastAPI via Uvicorn
57
- WORKDIR /app
58
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
59
-
 
 
 
 
 
 
 
 
1
  FROM python:3.10-slim
2
 
3
+ # Set environment variables
4
+ ENV HF_HOME=/app/hf
5
+ ENV PYTHONUNBUFFERED=1
6
+ ENV PIP_NO_CACHE_DIR=1
7
 
8
+ # Install system dependencies
9
+ RUN apt-get update && apt-get install -y \
10
+ ffmpeg \
11
+ libsndfile1 \
12
+ git \
 
 
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
+ # Set working directory
16
  WORKDIR /app
17
 
18
+ # Copy requirements and install Python packages
19
+ COPY requirements.txt .
20
+ RUN pip install --root-user-action=ignore -r requirements.txt
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
+ # Copy app files
23
  COPY . .
24
 
25
+ # Expose port
 
 
 
 
 
 
26
  EXPOSE 7860
27
 
28
+ # Run the app
 
29
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]