Spaces:
Sleeping
Sleeping
File size: 1,153 Bytes
db10255 a08bca9 db10255 |
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 |
# Dockerfile for HandyHome OCR API
FROM python:3.9-slim
# Install system dependencies for PaddleOCR and OpenCV
RUN apt-get update && apt-get install -y \
libglib2.0-0 \
libsm6 \
libxext6 \
libxrender-dev \
libgomp1 \
libgthread-2.0-0 \
libgl1 \
libglib2.0-0 \
curl \
wget \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy and install Python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Download PaddleOCR models during build to speed up first run
RUN python -c "from paddleocr import PaddleOCR; ocr = PaddleOCR(lang='en')"
# Copy application code
COPY . .
# Create non-root user for security
RUN useradd --create-home --shell /bin/bash app && chown -R app:app /app
USER app
EXPOSE 7860
# Health check
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
CMD curl -f http://localhost:7860/health || exit 1
# Use Gunicorn for production
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "300", "--max-requests", "1000", "--max-requests-jitter", "100", "app:app"]
|