File size: 1,668 Bytes
4096cd6 fb30b3d 9848af6 fb30b3d 4096cd6 9848af6 fb30b3d e0b4d0a 9848af6 e0b4d0a eb3a1f5 9848af6 eb3a1f5 9848af6 e0b4d0a eb3a1f5 4096cd6 9848af6 4096cd6 eb3a1f5 9848af6 e0b4d0a 4096cd6 e0b4d0a 4096cd6 9848af6 e0b4d0a cfa82c7 4096cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | # FROM python:3.10-slim
# # Add system dependencies for OpenCV + Tesseract OCR
# RUN apt-get update && apt-get install -y \
# libgl1 \
# libglib2.0-0 \
# tesseract-ocr \
# && rm -rf /var/lib/apt/lists/*
# # Create non-root user (Hugging Face best practice)
# RUN useradd -m -u 1000 user
# USER user
# ENV PATH="/home/user/.local/bin:$PATH"
# WORKDIR /app
# # Copy requirements and install
# COPY --chown=user requirements.txt .
# RUN pip install --no-cache-dir -r requirements.txt
# # Copy app code
# COPY --chown=user . /app
# # Expose port Hugging Face expects
# EXPOSE 7860
# # Run FastAPI with Uvicorn
# CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
# Dockerfile
FROM python:3.10-slim
# + ca-certificates (needed for Postgres TLS)
RUN apt-get update && apt-get install -y --no-install-recommends \
libgl1 \
libglib2.0-0 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Non-root user
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app
# Python deps
COPY --chown=user requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
# App code
COPY --chown=user . /app
# Perf + Ultralytics config dir
ENV OMP_NUM_THREADS=1 \
OPENBLAS_NUM_THREADS=1 \
UVICORN_WORKERS=2 \
YOLO_CONCURRENCY=1 \
HTTP_MAX_CONNECTIONS=50 \
DB_POOL_MAX=10 \
AUTH_CACHE_TTL_SECONDS=45 \
YOLO_CONFIG_DIR=/tmp/Ultralytics
RUN mkdir -p /tmp/Ultralytics
EXPOSE 7860
# Run via import string so multi-workers work cleanly
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "2"]
|