Spaces:
Running
Running
| # Multi-stage build for minimal image size | |
| FROM python:3.11-slim as builder | |
| WORKDIR /app | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| gcc g++ \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy and install Python dependencies | |
| COPY requirements.txt . | |
| RUN pip install --no-cache-dir --user -r requirements.txt | |
| # Runtime stage | |
| FROM python:3.11-slim | |
| WORKDIR /app | |
| # Copy installed packages from builder | |
| COPY --from=builder /root/.local /root/.local | |
| # Copy application code | |
| COPY src/ ./src/ | |
| COPY app/ ./app/ | |
| COPY config/ ./config/ | |
| COPY templates/ ./templates/ | |
| COPY .env .env | |
| # Add .local/bin to PATH | |
| ENV PATH=/root/.local/bin:$PATH | |
| # Expose FastAPI port | |
| EXPOSE 8000 | |
| # Health check | |
| HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ | |
| CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')" | |
| # Run FastAPI | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"] | |