Spaces:
Sleeping
Sleeping
| # Use official Python runtime as base image | |
| FROM python:3.11-slim | |
| # Set working directory in container | |
| WORKDIR /app | |
| # Install system dependencies needed for OpenCV and other libraries | |
| RUN apt-get update && apt-get install -y \ | |
| libglib2.0-0 \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender-dev \ | |
| libgomp1 \ | |
| libglu1-mesa \ | |
| libgl1 \ | |
| git \ | |
| && 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 the entire application | |
| COPY . . | |
| # Expose port 7860 (Hugging Face Spaces default) | |
| EXPOSE 7860 | |
| # Set environment variables | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV PORT=7860 | |
| # Run the application with gunicorn | |
| # Timeout is set to 300 seconds (5 minutes) for ML model loading | |
| CMD ["gunicorn", "main:app", "--bind", "0.0.0.0:7860", "--workers", "1", "--timeout", "300", "--access-logfile", "-"] | |