Spaces:
Sleeping
Sleeping
| # 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"] | |