| # Build React Frontend | |
| FROM node:18-slim AS builder | |
| WORKDIR /app/frontend | |
| COPY frontend/package*.json ./ | |
| RUN npm install | |
| COPY frontend/ ./ | |
| RUN npm run build | |
| # Final Stage: Python Backend | |
| FROM python:3.10-slim | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| ffmpeg \ | |
| gcc \ | |
| python3-dev \ | |
| git \ | |
| libsndfile1 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # Create necessary directories | |
| RUN mkdir -p /app/uploads /app/models /app/frontend/dist | |
| RUN chmod -R 777 /app | |
| # Upgrade pip and install build tools | |
| RUN pip install --no-cache-dir --upgrade pip setuptools wheel Cython | |
| # Install Torch CPU specifically (Essential for HF Spaces CPU tier) | |
| RUN pip install --no-cache-dir torch==2.5.1 torchaudio==2.5.1 --index-url https://download.pytorch.org/whl/cpu | |
| # Install remaining dependencies (WhisperX will pull its required pyannote version here) | |
| COPY backend/requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy backend source | |
| COPY backend/ . | |
| # Copy frontend build from builder stage | |
| COPY --from=builder /app/frontend/dist /app/frontend/dist | |
| # Metadata for HF | |
| ENV HOME=/app | |
| ENV PYTHONUNBUFFERED=1 | |
| EXPOSE 7860 | |
| CMD ["python", "main.py"] | |