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"]