FROM python:3.11-slim # Install system-level libraries required by opencv-python-headless RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install Python dependencies first (layer-cacheable) COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy application code COPY . . # Ensure the model directory exists (weights are uploaded separately on HF Spaces) RUN mkdir -p model # Hugging Face Spaces expects the service on port 7860 EXPOSE 7860 CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]