# ───────────────────────────────────────────────────────────────────────────── # ONNX Grid Vision API — Docker Deployment Configuration # ───────────────────────────────────────────────────────────────────────────── # Deploys a FastAPI grid classification service that uses: # - patchright (Chromium browser automation) # - ONNX Runtime (image classification/segmentation) # - Pillow (image processing) # # Port: 7860 # ───────────────────────────────────────────────────────────────────────────── FROM python:3.11-slim # ── System dependencies for Chromium ──────────────────────────────────────── RUN apt-get update && apt-get install -y --no-install-recommends \ libnss3 \ libatk1.0-0 \ libatk-bridge2.0-0 \ libcups2 \ libdrm2 \ libxkbcommon0 \ libxcomposite1 \ libxdamage1 \ libxfixes3 \ libxrandr2 \ libgbm1 \ libpango-1.0-0 \ libcairo2 \ libasound2 \ libatspi2.0-0 \ libxshmfence1 \ curl \ libjpeg62-turbo \ libpng16-16 \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # ── Python dependencies ──────────────────────────────────────────────────── COPY requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # ── Install Chromium via patchright ──────────────────────────────────────── RUN patchright install chromium # ── Copy application code ───────────────────────────────────────────────── COPY app.py . COPY browser_engine.py . COPY grid_classifier.py . COPY models/ ./models/ # ── Environment ──────────────────────────────────────────────────────────── ENV PYTHONUNBUFFERED=1 ENV PORT=7860 # ── Health check ─────────────────────────────────────────────────────────── HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -f http://localhost:7860/health || exit 1 # ── Run ──────────────────────────────────────────────────────────────────── CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]