Shaikhsarib commited on
Commit
ef0509c
·
verified ·
1 Parent(s): 6cc1d85

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +18 -16
Dockerfile CHANGED
@@ -1,31 +1,33 @@
 
 
 
 
 
 
 
 
 
 
1
  FROM python:3.11-slim
2
 
3
  WORKDIR /app
4
 
5
- # Install system dependencies for OCR and Image Processing
6
  RUN apt-get update && apt-get install -y \
7
- libgl1 \
8
- libglib2.0-0 \
9
- libsm6 \
10
- libxext6 \
11
- libxrender1 \
12
- libgomp1 \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
- # Install Python requirements
16
- COPY requirements.txt .
17
- RUN pip install --no-cache-dir -r requirements.txt
18
 
19
- # Copy application files
20
  COPY main.py .
21
  COPY index.html .
22
 
23
- # Setup persistent cache for Hugging Face and EasyOCR
24
- RUN mkdir -p /app/.cache && chmod 777 /app/.cache
25
  ENV HF_HOME=/app/.cache
26
- ENV PYTHONUNBUFFERED=1
27
-
28
- # Run as non-root user for Hugging Face security compliance
29
  RUN useradd -m -u 1000 user && chown -R user:user /app
30
  USER user
31
 
 
1
+ # Build Stage
2
+ FROM python:3.11-slim as builder
3
+
4
+ WORKDIR /app
5
+ RUN apt-get update && apt-get install -y build-essential
6
+
7
+ COPY requirements.txt .
8
+ RUN pip install --no-cache-dir --user -r requirements.txt
9
+
10
+ # Final Stage
11
  FROM python:3.11-slim
12
 
13
  WORKDIR /app
14
 
15
+ # Install runtime libs for OpenCV/OCR
16
  RUN apt-get update && apt-get install -y \
17
+ libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 libgomp1 \
 
 
 
 
 
18
  && rm -rf /var/lib/apt/lists/*
19
 
20
+ # Copy installed packages from builder
21
+ COPY --from=builder /root/.local /root/.local
22
+ ENV PATH=/root/.local/bin:$PATH
23
 
24
+ # Setup App
25
  COPY main.py .
26
  COPY index.html .
27
 
28
+ # Permissions & Cache & Data Folder
29
+ RUN mkdir -p /app/.cache /app/data && chmod 777 /app/.cache /app/data
30
  ENV HF_HOME=/app/.cache
 
 
 
31
  RUN useradd -m -u 1000 user && chown -R user:user /app
32
  USER user
33