| # Dockerfile for Hugging Face Spaces | |
| # Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker | |
| FROM python:3.12-slim | |
| # Create non-root user (HF Spaces requirement) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| # Set environment variables | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| ENV PYTHONUNBUFFERED=1 | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy requirements file | |
| COPY --chown=user requirements.txt /app/requirements.txt | |
| # Install PyTorch (CPU-only for efficiency) | |
| RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu | |
| # Install other Python dependencies | |
| RUN pip install --no-cache-dir -r /app/requirements.txt | |
| # Copy application code | |
| COPY --chown=user . /app | |
| # Expose port 7860 (required by HF Spaces) | |
| EXPOSE 7860 | |
| # Run Gradio app | |
| CMD ["python", "app.py"] | |