# Multi-stage / Production Dockerfile for AI Document Intelligence OCR on Google Cloud Run FROM python:3.10-slim # Prevent Python from writing .pyc files and buffer stdout/stderr ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PORT=8080 WORKDIR /app # Install system dependencies for OpenCV, Pillow, PaddleOCR, and ONNX RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ curl \ libgl1 \ libglib2.0-0 \ libgomp1 \ libgstreamer1.0-0 \ && rm -rf /var/lib/apt/lists/* # Install python dependencies COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy application source code COPY src/ ./src/ COPY app.py . COPY frontend.py . # Health check probe HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ CMD curl -f http://localhost:${PORT}/health || exit 1 # Expose container port EXPOSE 8080 # Run FastAPI with uvicorn listening on $PORT (Google Cloud Run dynamically injects PORT) CMD ["sh", "-c", "uvicorn app:app --host 0.0.0.0 --port ${PORT:-8080} --workers 1"]