File size: 871 Bytes
4bf0aa2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.9-slim

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    libgl1-mesa-glx \
    libgomp1 \
    libsm6 \
    libxext6 \
    libxrender-dev \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements
COPY requirements.txt .

# Install python dependencies
# Using a mirror or specific install command for paddle might be safer, 
# but pip install -r usually works for cpu versions.
RUN pip install --no-cache-dir -r requirements.txt

# Download the model files by running a dummy OCR once or explicitly downloading
# PaddleOCR downloads models to ~/.paddleocr by default
# We can pre-trigger this.
RUN python -c "from paddleocr import PaddleOCR; PaddleOCR(use_angle_cls=True, lang='en', use_gpu=False)"

# Copy source code
COPY ocr_server.py .

# Expose port
EXPOSE 5001

# Command to run
CMD ["python", "ocr_server.py"]