File size: 1,079 Bytes
35870a4 | 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 | FROM python:3.10-slim
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
HF_HOME=/app/.cache/huggingface \
HF_HUB_DISABLE_TELEMETRY=1 \
TOKENIZERS_PARALLELISM=false \
TORCH_NUM_THREADS=2 \
OMP_NUM_THREADS=2 \
MKL_NUM_THREADS=2 \
PORT=7860
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
libgomp1 \
&& rm -rf /var/lib/apt/lists/*
RUN useradd --create-home --uid 1000 appuser \
&& mkdir -p /app /app/.cache/huggingface \
&& chown appuser:appuser /app /app/.cache /app/.cache/huggingface
WORKDIR /app
COPY --chown=appuser:appuser requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
USER appuser
COPY --chown=appuser:appuser app.py .
# Download the official OmDet-Turbo processor and checkpoint during the build.
# API requests therefore require no model download and no Hugging Face token.
RUN python -c "from app import prepare_model_assets; prepare_model_assets()"
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"]
|