Spaces:
Sleeping
Sleeping
| # Use the official Python 3.11 slim image | |
| FROM python:3.11-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies required for OpenCV and other ML libraries | |
| RUN apt-get update && apt-get install -y \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements file first to leverage Docker cache | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| # Using --no-cache-dir to keep the image size small | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r requirements.txt | |
| # Hugging Face Spaces require running as a non-root user (UID 1000) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| # Set environment variables | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH \ | |
| PYTHONUNBUFFERED=1 | |
| # Copy the rest of the application code | |
| COPY --chown=user:user . . | |
| # Expose port 7860, which is the default for Hugging Face Spaces | |
| EXPOSE 7860 | |
| # Command to run the FastAPI application using uvicorn | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] | |