FROM python:3.11.9-slim # 1) System deps RUN apt-get update && apt-get install -y \ build-essential \ curl \ software-properties-common \ git \ && rm -rf /var/lib/apt/lists/* # 2) Create app user with home dir RUN useradd -m -u 10001 -s /usr/sbin/nologin appuser WORKDIR /app # Make sure /app is owned by our user RUN chown appuser:appuser /app # 3) Copy & install Python deps as root COPY requirements.txt . RUN pip3 install -r requirements.txt # 4) Copy your source & switch to non‑root COPY src/ ./src/ USER appuser # 5) Ensure Streamlit config dir exists in the new home ENV HOME=/home/appuser \ STREAMLIT_DATA_DIR=/home/appuser/.streamlit \ XDG_CONFIG_HOME=/home/appuser/.streamlit RUN mkdir -p /home/appuser/.streamlit EXPOSE 8501 HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health ENTRYPOINT ["streamlit", "run", "src/app.py", "--server.port=8501", "--server.address=0.0.0.0"]