# syntax=docker/dockerfile:1.6 FROM python:3.11-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 \ HF_HOME=/tmp/hf \ XDG_CACHE_HOME=/tmp/cache # System deps: libgomp needed by XGBoost/LightGBM runtime. RUN apt-get update \ && apt-get install -y --no-install-recommends libgomp1 \ && rm -rf /var/lib/apt/lists/* # HuggingFace Spaces expects a non-root user with UID 1000 and writable /home. RUN useradd -m -u 1000 app WORKDIR /home/app COPY --chown=app:app requirements.txt . # CPU-only torch wheel (about 200 MB vs ~2 GB for the CUDA build) RUN pip install --no-cache-dir --index-url https://download.pytorch.org/whl/cpu "torch>=2.2,<2.8" \ && pip install --no-cache-dir -r requirements.txt COPY --chown=app:app app.py ./ COPY --chown=app:app ml_torch.py ./ COPY --chown=app:app ml ./ml COPY --chown=app:app models ./models COPY --chown=app:app README.md ./README.md USER app EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]