| FROM python:3.11-slim | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| tesseract-ocr \ | |
| tesseract-ocr-eng \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| WORKDIR /app | |
| # Copy requirements | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application | |
| COPY app.py . | |
| # Expose port 7860 (Hugging Face standard) | |
| EXPOSE 7860 | |
| # Health check using port 7860 | |
| HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=5 \ | |
| CMD python -c "import requests; requests.get('http://localhost:7860/health', timeout=10)" | |
| # Run the application on port 7860 | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |