Spaces:
Sleeping
Sleeping
# Use the official Python 3.10.9 image | |
FROM python:3.10.9 | |
# Copy the current directory contents into the container at / | |
COPY . . | |
# Set the working directory to / | |
WORKDIR / | |
# Install system dependencies for OpenCV and other libraries | |
RUN apt-get update && apt-get install -y libgl1-mesa-glx curl && apt-get clean | |
# Set writable directories for Matplotlib and YOLO | |
ENV MPLCONFIGDIR=/tmp | |
ENV YOLO_CONFIG_DIR=/tmp | |
# Pre-download the YOLO model to a writable directory | |
RUN mkdir -p /tmp/models && \ | |
curl -L https://github.com/ultralytics/assets/releases/download/v8.3.0/yolov9s.pt -o /tmp/models/yolov9s.pt | |
# Install Python dependencies from requirements.txt | |
RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
# Start the FastAPI app on port 7860, the default port expected by Spaces | |
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |