File size: 1,394 Bytes
0c6d0a6
 
 
 
 
 
 
 
 
190a6c4
 
 
 
 
0c6d0a6
 
786b72a
 
0c6d0a6
 
 
 
 
 
 
 
 
 
 
 
 
29b213f
 
190a6c4
 
29b213f
0c6d0a6
 
 
29b213f
0c6d0a6
952ff40
 
0c6d0a6
 
 
 
 
 
 
190a6c4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# ============================================================
# Dockerfile — Hugging Face Spaces (Docker SDK)
# Custom OCR pipeline. No Tesseract.
# ============================================================

FROM python:3.9-slim

# ----- System dependencies for OpenCV & image processing -----
RUN apt-get update && apt-get install -y --no-install-recommends \
    libgl1 \
    libglib2.0-0 \
    libsm6 \
    libxext6 \
    libxrender-dev \
    && rm -rf /var/lib/apt/lists/*



# ----- Create non-root user (HF Spaces requirement, UID 1000) -----
RUN useradd -m -u 1000 appuser

# ----- Set working directory -----
WORKDIR /app

# ----- Install Python deps (cached layer) -----
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# ----- Copy application source -----
COPY . .

# ----- Create cache & upload directories -----
RUN mkdir -p /app/.cache/easyocr/model \
    /app/.cache/huggingface \
    /app/uploads

# ----- Ensure appuser owns everything -----
RUN chown -R appuser:appuser /app

# ----- Model cache paths -----
ENV HF_HOME=/app/.cache/huggingface
ENV EASYOCR_MODULE_PATH=/app/.cache/easyocr

# ----- Switch to non-root user -----
USER appuser

# ----- Expose HF Spaces required port -----
EXPOSE 7860

# ----- Run with Gunicorn -----
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--threads", "2", "--timeout", "99999", "app:app"]