File size: 1,361 Bytes
a1bbf36
 
a371525
460e2f4
a1bbf36
 
460e2f4
 
a1bbf36
 
460e2f4
 
a1bbf36
 
460e2f4
a1bbf36
 
 
f2d28f0
a1bbf36
 
 
460e2f4
a1bbf36
 
 
 
 
460e2f4
 
a1bbf36
f2d28f0
a1bbf36
 
f2d28f0
a1bbf36
 
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
# ---------------------------------------------------------------------
# Base image – use the full tag so `wget` is available for the steps
FROM python:3.9

# ---------------------------------------------------------------------
# 1. Create UID-1000 account *and its home directory*.
RUN useradd -m -u 1000 user

# Environment: declare the home dir now (some HF-injected commands
# look at $HOME) but stay root for the next layers.
ENV HOME=/home/user \
    PYTHONUNBUFFERED=1 \
    PIP_NO_CACHE_DIR=1 \
    PATH="$HOME/.local/bin:$PATH"

# ---------------------------------------------------------------------
# 2. Install Python dependencies **as root** so the console scripts
#    land in /usr/local/bin (already on PATH at runtime).
WORKDIR /app
COPY requirements.txt /tmp/reqs.txt
RUN pip install --no-cache-dir -r /tmp/reqs.txt \
 && rm /tmp/reqs.txt

# ---------------------------------------------------------------------
# 3. Switch to the non-root user for the final image,
#    then copy the source tree.
USER user
WORKDIR $HOME/app
COPY --chown=user . .

# ---------------------------------------------------------------------
# 4. Launch: $PORT is set by the platform at runtime; fall back to 8501
#    for local docker runs.
CMD streamlit run app.py \
    --server.port=${PORT:-8501} \
    --server.headless true \
    --server.address 0.0.0.0