FROM python:3.11-slim # OpenCV (ultralytics' transitive dep) needs libGL + libglib for image decoding. RUN apt-get update && apt-get install -y --no-install-recommends \ libgl1 libglib2.0-0 \ && rm -rf /var/lib/apt/lists/* WORKDIR /home/user/app COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt COPY . /home/user/app/ # Pre-bake the FastSAM weight (~23 MB) into the image so the first # /api/sam/point call doesn't pay a one-time network download. RUN python -c "from ultralytics import FastSAM; FastSAM('FastSAM-s.pt')" ENV PYTHONUNBUFFERED=1 EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]