File size: 1,027 Bytes
de7320e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
eb4ae44
de7320e
 
 
 
 
 
 
 
 
 
 
 
8e20461
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
FROM python:3.11-slim

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

WORKDIR /app

# Install CUDA-enabled torch FIRST so pip satisfies torch>=2.5.0
# from the CUDA index rather than pulling the CPU-only wheel from PyPI.
RUN pip install --no-cache-dir \
    "torch>=2.5.0,<3.0" "torchaudio>=2.5.0,<3.0" \
    --index-url https://download.pytorch.org/whl/cu121

COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

COPY . .
RUN mkdir -p /app/temp /app/model_cache

ENV MPLBACKEND=Agg
ENV PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
ENV HF_HOME=/app/model_cache
ENV GRADIO_ANALYTICS_ENABLED=false
ENV PYTHONPATH=/app
ENV CONFIG_PATH=/app/config/settings.yaml

# HF Spaces requires the process to run as UID 1000
RUN adduser --disabled-password --gecos '' --uid 1000 hfuser \
    && chown -R hfuser:hfuser /app
USER 1000

EXPOSE 7860

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