File size: 875 Bytes
a5ab371
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
FROM python:3.11-slim

# System libraries needed by scipy/scikit-learn/matplotlib wheels and shap's build step
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential \
    libgomp1 \
    && rm -rf /var/lib/apt/lists/*

# Hugging Face Spaces runs containers as a non-root user by convention
RUN useradd -m -u 1000 appuser
USER appuser
ENV HOME=/home/appuser \
    PATH=/home/appuser/.local/bin:$PATH

WORKDIR /home/appuser/app

COPY --chown=appuser:appuser requirements.txt .
RUN pip install --no-cache-dir --user -r requirements.txt

COPY --chown=appuser:appuser app.py .

# Hugging Face Docker Spaces expect the app to listen on port 7860
ENV PORT=7860 \
    WORK_ROOT=/home/appuser/app/runs \
    MPLCONFIGDIR=/home/appuser/app/.mplcache
RUN mkdir -p /home/appuser/app/runs /home/appuser/app/.mplcache

EXPOSE 7860

CMD ["python", "app.py"]