| # Use Python 3.11 slim image | |
| FROM python:3.11-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first for better caching | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application files | |
| COPY . . | |
| # Expose port 7860 (HuggingFace Spaces default) | |
| EXPOSE 7860 | |
| # Set environment variables | |
| ENV FLASK_APP=app.py | |
| ENV PYTHONUNBUFFERED=1 | |
| # Run the application with gunicorn | |
| CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "120", "app:app"] | |