Spaces:
Sleeping
Sleeping
| FROM python:3.10-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Install system dependencies (including curl for health checks) | |
| RUN apt-get update && apt-get install -y \ | |
| git \ | |
| curl \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy requirements first for better caching | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy application code | |
| COPY . . | |
| # Create outputs directory for model artifacts (will be downloaded from HF) | |
| RUN mkdir -p outputs/phase2_swin_base_production/models | |
| # Expose port 7860 (HF Spaces default) | |
| EXPOSE 7860 | |
| # Health check to ensure the API is running | |
| HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \ | |
| CMD curl -f http://localhost:7860/health || exit 1 | |
| # Start the FastAPI application with uvicorn | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860", "--workers", "1"] |