File size: 1,009 Bytes
a2f5871
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c9c417c
 
 
a2f5871
 
c9c417c
a2f5871
 
 
 
 
 
 
 
 
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
# 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"]