File size: 1,099 Bytes
b47954d
 
8329562
a467c34
b47954d
 
a467c34
c131b3a
 
 
 
c8deba6
b47954d
c8deba6
b47954d
c8deba6
c131b3a
 
 
 
b47954d
c131b3a
 
 
b47954d
c131b3a
b47954d
a467c34
 
b47954d
1fdb2f4
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
FROM python:3.11-slim

# System deps
RUN apt-get update && apt-get install -y --no-install-recommends curl && \
    rm -rf /var/lib/apt/lists/*

# Non-root user
RUN useradd -m -u 1000 appuser

WORKDIR /app

# ── Python deps (changes only when requirements.txt changes) ──────
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# ── App code (changes often β€” always last) ────────────────────────
COPY --chown=appuser:appuser . .

ENV PYTHONPATH=/app:$PYTHONPATH \
    HOME=/home/appuser

RUN mkdir -p /home/appuser/.streamlit && \
    printf '[server]\nheadless = true\nport = 7860\nenableCORS = false\nenableXsrfProtection = false\n' > /home/appuser/.streamlit/config.toml && \
    chown -R appuser:appuser /home/appuser/.streamlit /app

USER appuser
EXPOSE 7860
HEALTHCHECK --interval=30s --timeout=60s --start-period=120s --retries=3 \
    CMD curl --fail http://localhost:7860/_stcore/health || exit 1

ENTRYPOINT ["streamlit", "run", "app/main.py", "--server.port=7860", "--server.address=0.0.0.0"]