Spaces:
Sleeping
Sleeping
| # ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Eatlytic 2.0 β Multi-stage Docker build | |
| # New in v2: reportlab (PDF export), twilio (WhatsApp bot), | |
| # Hindi OCR model pre-download, /health endpoint | |
| # ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # ββ Stage 1: Builder βββββββββββββββββββββββββββββββββββββββββββββββ | |
| FROM python:3.11-slim AS builder | |
| WORKDIR /app | |
| RUN apt-get update && apt-get install -y --no-install-recommends build-essential && \ | |
| rm -rf /var/lib/apt/lists/* | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir --prefix=/install -r requirements.txt | |
| # ββ Stage 2: Runtime βββββββββββββββββββββββββββββββββββββββββββββββ | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # Runtime libs required by OpenCV / EasyOCR | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libgl1 libglib2.0-0 libsm6 libxext6 libxrender1 libgomp1 curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy installed Python packages from builder | |
| COPY --from=builder /install /usr/local | |
| # App source | |
| COPY main.py . | |
| COPY index.html . | |
| # Persistent directories for cache & data | |
| RUN mkdir -p /app/.cache /app/data && chmod 777 /app/.cache /app/data | |
| ENV HF_HOME=/app/.cache | |
| ENV PYTHONUNBUFFERED=1 | |
| # Non-root user | |
| RUN useradd -m -u 1000 user && chown -R user:user /app | |
| USER user | |
| # Port | |
| EXPOSE 7860 | |
| # Health check β hits the /health endpoint every 30s | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ | |
| CMD curl -f http://localhost:7860/health || exit 1 | |
| # Async-ready startup: 2 workers, async event loop | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860", \ | |
| "--workers", "1", "--loop", "asyncio", "--log-level", "info"] |