| # Use a small but recent base | |
| FROM python:3.10-slim | |
| # Create writable tmp directory early (HF Spaces requirement) | |
| RUN mkdir -p /tmp && chmod -R 777 /tmp | |
| ENV TMPDIR=/tmp | |
| # Allow apt installs for system deps (opencv needs libgl1, etc.) | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # Copy requirements first (for caching) | |
| COPY requirements.txt . | |
| # Install pip deps | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy app code | |
| COPY . . | |
| # Expose the port Spaces expects by default | |
| EXPOSE 7860 | |
| # Run uvicorn on port 7860 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"] | |