Spaces:
Sleeping

File size: 1,340 Bytes
e350ea0
62e14a8
 
e350ea0
62e14a8
5b4d2a8
e350ea0
 
 
 
 
 
5b4d2a8
e350ea0
5b4d2a8
e350ea0
 
 
5b4d2a8
e350ea0
 
5b4d2a8
e350ea0
 
 
 
 
 
 
 
 
5b4d2a8
e350ea0
 
 
 
b1eee64
e350ea0
 
 
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
39
40
41
# Use a stable base with wide wheel support
FROM python:3.13.5-slim

# Create non-root user matching HF Spaces expectations
RUN useradd -m -u 1000 user

# Environment & paths (install to user site-packages)
ENV HOME=/home/user \
    PATH=/home/user/.local/bin:$PATH \
    PIP_NO_CACHE_DIR=1 \
    STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \
    STREAMLIT_USER_SETTINGS_DIR=/home/user/.streamlit

WORKDIR $HOME/app

# Optional system tools (if you truly need git/curl/build tools)
# RUN apt-get update && apt-get install -y --no-install-recommends \
#     curl git build-essential && rm -rf /var/lib/apt/lists/*

# Switch to the non-root user BEFORE pip so deps install to ~/.local
USER user

# Dependencies first for better layer caching
COPY --chown=user requirements.txt .
RUN pip install -r requirements.txt

# App code
COPY --chown=user . .

# Ensure Streamlit settings dir exists & is writable
RUN mkdir -p "$STREAMLIT_USER_SETTINGS_DIR"

# Hugging Face sets $PORT; bind to it. Locally defaults to 8501.
ENTRYPOINT ["bash","-lc","streamlit run src/streamlit_app.py --server.port=${PORT:-8501} --server.address=0.0.0.0"]

EXPOSE 8501

# Healthcheck (uses shell so $PORT expands)
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
  CMD bash -lc 'curl -fsS http://127.0.0.1:${PORT:-8501}/_stcore/health || exit 1'