| |
| |
| |
| |
|
|
| |
| FROM python:3.11-slim AS builder |
|
|
| WORKDIR /build |
|
|
| |
| RUN apt-get update && \ |
| apt-get install -y --no-install-recommends gcc g++ && \ |
| rm -rf /var/lib/apt/lists/* |
|
|
| COPY requirements.txt . |
|
|
| |
| RUN pip install --no-cache-dir --prefix=/install \ |
| torch torchvision --index-url https://download.pytorch.org/whl/cpu |
|
|
| |
| RUN pip install --no-cache-dir --prefix=/install -r requirements.txt |
|
|
|
|
| |
| FROM python:3.11-slim AS runtime |
|
|
| LABEL maintainer="AI Certificate Verification Service" |
| LABEL description="FastAPI-based certificate verification with YOLO & ViT models" |
|
|
| |
| ENV PYTHONUNBUFFERED=1 \ |
| PYTHONDONTWRITEBYTECODE=1 \ |
| APP_HOME=/app \ |
| PORT=8080 \ |
| WORKERS=1 \ |
| LOG_LEVEL=info \ |
| SKIP_MODEL_LOADING=true \ |
| GUNICORN_TIMEOUT=300 \ |
| GUNICORN_KEEP_ALIVE=5 \ |
| GUNICORN_GRACEFUL_TIMEOUT=120 \ |
| |
| HF_HUB_DISABLE_TELEMETRY=1 \ |
| TRANSFORMERS_OFFLINE=0 \ |
| |
| OMP_NUM_THREADS=2 \ |
| MKL_NUM_THREADS=2 |
|
|
| WORKDIR $APP_HOME |
|
|
| |
| RUN apt-get update && \ |
| apt-get install -y --no-install-recommends \ |
| libgl1 \ |
| libglib2.0-0 \ |
| libsm6 \ |
| libxext6 \ |
| libxrender1 \ |
| curl \ |
| tini && \ |
| rm -rf /var/lib/apt/lists/* && \ |
| |
| groupadd -r appuser && \ |
| useradd -r -g appuser -d $APP_HOME -s /sbin/nologin appuser |
|
|
| |
| COPY --from=builder /install /usr/local |
|
|
| |
| COPY api.py ocr_client.py verifier_supabase.py verifier.py \ |
| yolo_seal_detector.py yolo_new.py vit_seal_classifier.py \ |
| image_annotator.py model_downloader.py \ |
| ./ |
|
|
| |
|
|
| |
| COPY gunicorn.conf.py ./ |
| COPY entrypoint.sh ./ |
|
|
| |
| RUN chmod +x entrypoint.sh |
|
|
| |
| RUN mkdir -p /app/models /app/tmp && \ |
| chown -R appuser:appuser /app |
|
|
| |
| USER appuser |
|
|
| |
| EXPOSE ${PORT} |
|
|
| |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=120s --retries=3 \ |
| CMD curl -f http://localhost:${PORT}/health || exit 1 |
|
|
| |
| ENTRYPOINT ["tini", "--"] |
|
|
| |
| CMD ["./entrypoint.sh"] |