OCR / Dockerfile
Rivalcoder
Add files
2f465bd
FROM python:3.10-slim
# System dependencies
RUN apt-get update && apt-get install -y \
poppler-utils \
tesseract-ocr \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# EasyOCR model dir (must be writable)
ENV EASY_OCR_DIR=/app/.EasyOCR
RUN mkdir -p $EASY_OCR_DIR/user_network
# Copy requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# ⚡ Pre-download EasyOCR detection + recognition models
RUN python3 - <<'EOF'
import easyocr, os
MODEL_DIR = "/app/.EasyOCR"
USER_NET_DIR = os.path.join(MODEL_DIR, "user_network")
os.makedirs(MODEL_DIR, exist_ok=True)
os.makedirs(USER_NET_DIR, exist_ok=True)
# preload both en + hi recognition + detection
reader = easyocr.Reader(['en', 'hi'],
model_storage_directory=MODEL_DIR,
user_network_directory=USER_NET_DIR,
download_enabled=True
)
EOF
# Copy app
COPY app.py .
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]