# Secure RAG + Shield (Streamlit). The local model runs in a separate container (see docker-compose.yml). FROM python:3.11-slim ENV PYTHONUNBUFFERED=1 PIP_NO_CACHE_DIR=1 STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \ STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false STREAMLIT_SERVER_ENABLE_CORS=false WORKDIR /app # Python packages first, so Docker can reuse this layer COPY requirements.txt . RUN pip install -r requirements.txt # The code. The .dockerignore file keeps out: data/, tests, notebooks, documents, keys and secrets. COPY . . # Empty secrets file: keys come from the environment (.env), so Streamlit must not show "No secrets files found" RUN mkdir -p /app/.streamlit && touch /app/.streamlit/secrets.toml # Run as a normal user, not as root RUN useradd -m appuser && chown -R appuser /app USER appuser EXPOSE 8501 HEALTHCHECK --interval=30s --timeout=5s --start-period=20s \ CMD python -c "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://localhost:8501/_stcore/health').status==200 else 1)" CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.headless=true"]