muddasser commited on
Commit
ee0f034
·
verified ·
1 Parent(s): a1e494c

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -7
Dockerfile CHANGED
@@ -12,31 +12,36 @@ RUN python -m venv /opt/venv && \
12
  /opt/venv/bin/pip install --upgrade pip && \
13
  /opt/venv/bin/pip install --no-cache-dir -r requirements.txt
14
 
15
- # Pre-download YOLOv8 weights to the exact path Ultralytics expects
16
  RUN mkdir -p /root/.cache/torch/hub/checkpoints && \
17
  curl -L -o /root/.cache/torch/hub/checkpoints/yolov8n.pt \
18
  https://github.com/ultralytics/assets/releases/download/v8.3.0/yolov8n.pt
19
 
20
- # Stage 2 - Final
21
  FROM python:3.10-slim
22
  ENV DEBIAN_FRONTEND=noninteractive
23
  ENV PATH="/opt/venv/bin:$PATH"
24
 
25
- # Force EasyOCR to store in /app/.EasyOCR instead of /
26
  ENV EASYOCR_MODULE_PATH=/app/.EasyOCR
27
  ENV EASYOCR_CACHE_DIR=/app/.EasyOCR
28
 
 
 
 
29
  RUN apt-get update && apt-get install -y --no-install-recommends \
30
  libgl1 libglib2.0-0 \
31
  && rm -rf /var/lib/apt/lists/*
32
 
33
  COPY --from=builder /opt/venv /opt/venv
34
- COPY --from=builder /root/.cache/torch/hub/checkpoints/yolov8n.pt \
35
- /root/.cache/torch/hub/checkpoints/yolov8n.pt
36
 
37
  WORKDIR /app
38
- # Create EasyOCR cache folder and set permissions
39
- RUN mkdir -p /app/.EasyOCR && chmod -R 777 /app/.EasyOCR
 
 
 
40
 
41
  COPY . .
42
 
 
12
  /opt/venv/bin/pip install --upgrade pip && \
13
  /opt/venv/bin/pip install --no-cache-dir -r requirements.txt
14
 
15
+ # Pre-download YOLOv8n weights to Ultralytics expected cache path
16
  RUN mkdir -p /root/.cache/torch/hub/checkpoints && \
17
  curl -L -o /root/.cache/torch/hub/checkpoints/yolov8n.pt \
18
  https://github.com/ultralytics/assets/releases/download/v8.3.0/yolov8n.pt
19
 
20
+ # Stage 2 - Final Image
21
  FROM python:3.10-slim
22
  ENV DEBIAN_FRONTEND=noninteractive
23
  ENV PATH="/opt/venv/bin:$PATH"
24
 
25
+ # Fix EasyOCR cache location
26
  ENV EASYOCR_MODULE_PATH=/app/.EasyOCR
27
  ENV EASYOCR_CACHE_DIR=/app/.EasyOCR
28
 
29
+ # ✅ Force YOLO to use its cache folder, not cwd
30
+ ENV YOLO_CONFIG_DIR=/app/.yolo
31
+
32
  RUN apt-get update && apt-get install -y --no-install-recommends \
33
  libgl1 libglib2.0-0 \
34
  && rm -rf /var/lib/apt/lists/*
35
 
36
  COPY --from=builder /opt/venv /opt/venv
37
+ COPY --from=builder /root/.cache /root/.cache
 
38
 
39
  WORKDIR /app
40
+
41
+ # Create required cache folders and fix permissions
42
+ RUN mkdir -p /app/.EasyOCR /app/.yolo && \
43
+ chmod -R 777 /app && \
44
+ chmod -R 777 /root/.cache
45
 
46
  COPY . .
47