FROM python:3.10-slim ENV DEBIAN_FRONTEND=noninteractive ENV EASYOCR_MODULE_PATH=/app/.EasyOCR ENV YOLO_CONFIG_DIR=/app/.config/Ultralytics RUN apt-get update && apt-get install -y --no-install-recommends \ git curl build-essential ffmpeg libsm6 libxext6 file \ && apt-get clean && rm -rf /var/lib/apt/lists/* WORKDIR /app RUN mkdir -p /app/.EasyOCR /app/.config/Ultralytics \ && chmod -R 777 /app/.EasyOCR /app/.config/Ultralytics COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt RUN curl -L --retry 3 --retry-delay 5 -o /app/anpr_yolov8.pt \ "https://github.com/ultralytics/assets/releases/download/v8.2.0/yolov8n.pt" \ && [ -s /app/anpr_yolov8.pt ] || { echo "Error: Model download failed or file is empty"; exit 1; } \ && { file /app/anpr_yolov8.pt | grep -q -E "Python|data|gzip" || { echo "Error: anpr_yolov8.pt is not a valid file type"; exit 1; }; } COPY app.py . EXPOSE 7860 CMD ["python", "app.py"]