| FROM python:3.10-slim | |
| WORKDIR /app | |
| # Install system dependencies (ffmpeg for audio/video processing) | |
| RUN apt-get update && apt-get install -y \ | |
| ffmpeg \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first to leverage Docker cache | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the application code (excludes venv, models, .whl via .dockerignore) | |
| COPY . . | |
| # HuggingFace Spaces expects port 7860 | |
| EXPOSE 7860 | |
| # Set environment variables for HF deployment | |
| # IMPORTANT: Do NOT set TRANSFORMERS_OFFLINE or HF_HUB_OFFLINE here — models must download | |
| ENV TRANSFORMERS_CACHE=/app/cache | |
| ENV HF_HOME=/app/cache | |
| ENV TRANSFORMERS_OFFLINE=0 | |
| ENV HF_HUB_OFFLINE=0 | |
| ENV PORT=7860 | |
| # Create cache directory with write permissions | |
| RUN mkdir -p /app/cache /app/sessions && chmod -R 777 /app/cache /app/sessions | |
| # Start the FastAPI app via uvicorn on port 7860 | |
| CMD ["uvicorn", "fusion_engine:app", "--host", "0.0.0.0", "--port", "7860"] |