FROM python:3.11 # System deps for audio processing RUN apt-get update && \ apt-get install -y --no-install-recommends \ build-essential \ libsndfile1 \ ffmpeg \ && rm -rf /var/lib/apt/lists/* # HF runs containers as UID 1000 RUN useradd -m -u 1000 user WORKDIR /app # Install Python deps first (cached layer) COPY --chown=user requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir --prefer-binary -r requirements.txt # Copy app code COPY --chown=user . /app USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH EXPOSE 7860 CMD ["python", "app.py"]