File size: 1,094 Bytes
2606d6e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.11-slim

# ffmpeg for audio decode (muscriptor wraps torchaudio/soundfile),
# libsndfile1 for soundfile/librosa, git for `pip install git+…`.
RUN apt-get update && apt-get install -y --no-install-recommends \
        ffmpeg \
        libsndfile1 \
        git \
    && rm -rf /var/lib/apt/lists/*

ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    PORT=7860 \
    PIP_NO_CACHE_DIR=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1 \
    HF_HOME=/data/hf \
    TRANSFORMERS_CACHE=/data/hf \
    HUGGINGFACE_HUB_CACHE=/data/hf

WORKDIR /app

# Install deps first for better layer caching.
COPY requirements.txt /app/requirements.txt
RUN pip install -r /app/requirements.txt

# App
COPY app.py /app/app.py

# Persistent storage for muscriptor model weights + gradio cache
RUN mkdir -p /data/hf
VOLUME ["/data"]

EXPOSE 7860

HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \
    CMD python -c "import urllib.request,sys; \
sys.exit(0) if urllib.request.urlopen('http://127.0.0.1:7860/', timeout=5).status == 200 else sys.exit(1)"

CMD ["python", "app.py"]