| # Use a Python 3.10 slim image for a smaller footprint | |
| FROM python:3.10-slim | |
| # Install system dependencies (FFmpeg is critical for audio extraction) | |
| RUN apt-get update && apt-get install -y \ | |
| ffmpeg \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set up a non-root user (Hugging Face Spaces best practice) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| WORKDIR /app | |
| # Copy requirements first to leverage Docker cache | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Download spacy model (if you use it for NER/Patching) | |
| RUN python -m spacy download en_core_web_sm | |
| # Copy the rest of the application code | |
| COPY --chown=user . . | |
| # Create necessary directories for runtime | |
| RUN mkdir -p app/uploads app/subtitles logs | |
| # Expose the port Hugging Face expects | |
| EXPOSE 7860 | |
| # Run the FastAPI app using uvicorn | |
| # We use port 7860 as it is the default for HF Spaces | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] | |