# Use official Python slim image FROM python:3.11-slim # Install system dependencies for OpenCV RUN apt-get update && apt-get install -y \ libgl1 \ libglib2.0-0 \ ffmpeg \ && rm -rf /var/lib/apt/lists/* # Set environment variables to avoid permission issues ENV YOLO_CONFIG_DIR=/tmp/Ultralytics ENV MPLCONFIGDIR=/tmp/matplotlib # Set working directory WORKDIR /app # Copy and install Python dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy the application code COPY . . # Expose Flask port EXPOSE 7860 # Run Flask app CMD ["python", "app.py"]