Spaces:
Sleeping
Sleeping
| # Multi-stage build for Autonomous Traffic Control HF Space | |
| FROM python:3.11-slim as builder | |
| WORKDIR /build | |
| # Install build dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements | |
| COPY requirements.txt . | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir --user -r requirements.txt | |
| # Final stage | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # Install runtime dependencies | |
| # libgl1-mesa-glx and libglib2.0-0 are required for OpenCV | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| libsm6 \ | |
| libxext6 \ | |
| libxrender-dev \ | |
| libgl1 \ | |
| libglib2.0-0 \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy dependencies from builder | |
| COPY --from=builder /root/.local /root/.local | |
| # Set environment variables | |
| ENV PATH=/root/.local/bin:$PATH \ | |
| PYTHONUNBUFFERED=1 \ | |
| PYTHONDONTWRITEBYTECODE=1 \ | |
| STREAMLIT_SERVER_PORT=7860 \ | |
| STREAMLIT_SERVER_ADDRESS=0.0.0.0 \ | |
| STREAMLIT_BROWSER_GATHER_USAGE_STATS=false | |
| # Copy all application files and assets (models, videos, scripts) | |
| COPY . . | |
| # Expose the default HF Spaces port | |
| EXPOSE 7860 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ | |
| CMD streamlit hello || exit 1 | |
| # Default command runs the Streamlit dashboard | |
| CMD ["streamlit", "run", "dashboard_final.py", "--server.port", "7860", "--server.address", "0.0.0.0"] | |