# Use the official Python 3.11 image FROM python:3.11-slim # Install ffmpeg for pydub audio processing RUN apt-get update && apt-get install -y ffmpeg && rm -rf /var/lib/apt/lists/* # Set up a non-root user (required by Hugging Face Spaces) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ PYTHONPATH=/home/user/app # Set the working directory WORKDIR $HOME/app # Copy requirements and install them # We switch back to root temporarily to fix permissions if needed, but pip install --user works fine for non-root COPY --chown=user:user requirements.txt $HOME/app/ RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir --user -r requirements.txt # Copy the rest of the application code COPY --chown=user:user . $HOME/app/ # Expose port 7860, which is what Hugging Face Spaces expects EXPOSE 7860 # Start the FastAPI server on port 7860 CMD ["uvicorn", "src.api.main:app", "--host", "0.0.0.0", "--port", "7860"]