File size: 1,276 Bytes
f52cf1a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Base image: HF-style PyTorch GPU environment
FROM huggingface/transformers-pytorch-gpu:latest

# Avoid interactive prompts
ENV DEBIAN_FRONTEND=noninteractive

# System deps (adjust as needed: ffmpeg, sox, libsndfile, etc.)
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
        ffmpeg \
        sox \
        libsndfile1 && \
    rm -rf /var/lib/apt/lists/*

# Workdir for app code
WORKDIR /app

# Copy your repo code (same structure as your HF endpoint repo)
# If you build from local checkout:
COPY . /app

# Or if you want to clone from HF Hub instead, comment COPY above and use:
# RUN git clone https://huggingface.co/YOUR_USER/YOUR_COSYVOICE_REPO /app

# Install Python deps
# You should have a requirements.txt in the repo that includes:
# fastapi, uvicorn[standard], cosyvoice deps (torch, onnxruntime, pyworld, soundfile, etc.)
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# Expose API port
EXPOSE 8000

# Optional: envs for prod behavior
ENV PYTHONUNBUFFERED=1 \
    UVICORN_HOST=0.0.0.0 \
    UVICORN_PORT=8000

# Start FastAPI app with Uvicorn
# Assumes you have server.py with `app = FastAPI()` at top-level
CMD ["uvicorn", "server:app", "--host", "0.0.0.0", "--port", "8000"]