FROM python:3.11-slim # Install system deps for audio processing RUN apt-get update && apt-get install -y --no-install-recommends ffmpeg libsndfile1 && rm -rf /var/lib/apt/lists/* # Create non-root user (HF Spaces requirement) RUN useradd -m -u 1000 user # Create dirs BEFORE switching user RUN mkdir -p /home/user/app/checkpoints /home/user/app/data/training_data /home/user/app/logs && chown -R user:user /home/user/app ENV HOME=/home/user PATH=/home/user/.local/bin:$PATH PYTHONUNBUFFERED=1 PYTHONIOENCODING=UTF-8 HF_HOME=/home/user/.cache/huggingface PORT=7860 WORKDIR /home/user/app # Install Python deps COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt && pip install --no-cache-dir soundfile COPY . . USER user CMD ["python", "app.py"]