the_jerome_zone / Dockerfile
khobster's picture
Update Dockerfile
529ea69 verified
FROM python:3.10-slim
# Force fresh rebuilds when needed (change value to bust cache)
ARG CACHE_BUST=20260225_1
# System deps (git required for cloning GPT-SoVITS)
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
ffmpeg \
libsndfile1 \
build-essential \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# (Optional but nice) confirm Python/pip versions in build logs
RUN python --version && pip --version
RUN apt-get update && apt-get install -y ffmpeg && rm -rf /var/lib/apt/lists/*
# CPU Torch for build/testing (GPU hardware on Space is still recommended for speed)
RUN pip install --no-cache-dir torch==2.1.2 torchaudio==2.1.2 --index-url https://download.pytorch.org/whl/cpu
# Copy requirements first for better layer caching
COPY requirements.txt /app/requirements.txt
RUN pip install --no-cache-dir -r /app/requirements.txt
# Clone GPT-SoVITS into the exact path app.py expects, and VERIFY in build logs
RUN git --version && \
git clone --depth 1 https://github.com/RVC-Boss/GPT-SoVITS.git /app/GPT-SoVITS && \
ls -la /app && \
test -d /app/GPT-SoVITS && \
echo "✅ GPT-SoVITS cloned successfully"
# Copy the rest of your Space files (app.py, models, wav, README, etc.)
COPY . /app
# Ensure outputs/cache dirs exist
RUN mkdir -p /app/outputs /app/hf_cache
# Helpful startup sanity check script (optional but very useful)
RUN printf '%s\n' \
'#!/bin/sh' \
'echo "===== STARTUP CHECK ====="' \
'python --version' \
'echo "PWD: $(pwd)"' \
'ls -la /app | head -200' \
'if [ -d /app/GPT-SoVITS ]; then echo "✅ /app/GPT-SoVITS exists"; else echo "❌ /app/GPT-SoVITS missing"; fi' \
'echo "========================="' \
'exec python app.py' \
> /app/start.sh && chmod +x /app/start.sh
# Non-root user (HF-friendly)
RUN useradd -m -u 1000 user && chown -R user:user /app
USER user
ENV HF_HOME=/app/hf_cache
ENV PYTHONUNBUFFERED=1
ENV GRADIO_SERVER_NAME=0.0.0.0
ENV GRADIO_SERVER_PORT=7860
EXPOSE 7860
# IMPORTANT: app.py is Gradio
CMD ["/app/start.sh"]