Spaces:
Sleeping
Sleeping
| # 1. Base Image | |
| FROM python:3.10-slim | |
| # 2. Install Git + curl (for health checks) | |
| RUN apt-get update && \ | |
| apt-get install -y --no-install-recommends git curl && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # 3. Setup App | |
| WORKDIR /app | |
| # 4. Install Dependencies | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # 5. Copy Application | |
| COPY . . | |
| # 6. Create User | |
| RUN useradd -m -u 1000 user && \ | |
| chown -R user:user /app | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| # 7. Expose Port | |
| EXPOSE 7860 | |
| # 8. Add Health Check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ | |
| CMD curl -f http://localhost:7860/_stcore/health || exit 1 | |
| # 9. Run Streamlit | |
| CMD ["streamlit", "run", "app.py", \ | |
| "--server.port=7860", \ | |
| "--server.address=0.0.0.0", \ | |
| "--server.enableCORS=false", \ | |
| "--server.enableXsrfProtection=false", \ | |
| "--server.headless=true"] |