# Use python 3.11 slim as base image FROM python:3.11-slim # Set environment variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PORT=7860 # Install system dependencies (ffmpeg is required for audio extraction) RUN apt-get update && apt-get install -y --no-install-recommends \ ffmpeg \ && rm -rf /var/lib/apt/lists/* # Set up working directory WORKDIR /app # Create a non-root user (Hugging Face Spaces runs as user 1000) RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH # Set working directory inside user home or set permissions WORKDIR $HOME/app # Copy requirements and install COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the rest of the application COPY --chown=user . . # Expose the port FastAPI runs on EXPOSE 7860 # Start uvicorn server on port 7860 (Hugging Face default) CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]