# Base image FROM python:3.10-slim # Install system dependencies required by librosa / soundfile / ffmpeg RUN apt-get update && apt-get install -y \ libsndfile1 \ ffmpeg \ build-essential \ && rm -rf /var/lib/apt/lists/* # Create a non-root user (HF Spaces requirement) RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # Set working directory WORKDIR /app # Copy and install Python dependencies COPY --chown=user requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt \ && pip install --no-cache-dir gunicorn # Copy the entire project COPY --chown=user . . # Create needed directories RUN mkdir -p static/uploads database model # Hugging Face Spaces requires port 7860 EXPOSE 7860 # Run with gunicorn CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--timeout", "120", "--workers", "1", "app:app"]