FROM python:3.11-slim RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ STREAMLIT_SERVER_PORT=7860 \ STREAMLIT_SERVER_ADDRESS=0.0.0.0 \ STREAMLIT_SERVER_HEADLESS=true \ STREAMLIT_BROWSER_GATHER_USAGE_STATS=false WORKDIR $HOME/app COPY --chown=user requirements.txt ./ RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt COPY --chown=user . . # Pre-compute the crime and population caches so the app starts instantly. # If the build-time download fails, the app will build the cache at runtime. RUN python -c "import app; app.warm_cache()" \ || echo "warm cache skipped; will build at first run" EXPOSE 7860 CMD ["streamlit", "run", "app.py", \ "--server.port=7860", \ "--server.address=0.0.0.0", \ "--server.enableXsrfProtection=false"]