| FROM python:3.12-slim | |
| WORKDIR /app | |
| # Install dependencies first (layer caching) | |
| # Use slim requirements (no torch/chronos/streamlit — not needed at API runtime) | |
| COPY backend/requirements-docker.txt backend/ | |
| COPY backend/requirements.txt backend/ | |
| RUN pip install --no-cache-dir -r backend/requirements-docker.txt -r backend/requirements.txt | |
| # Non-root user for security | |
| RUN groupadd -r solarwine && useradd -r -g solarwine solarwine | |
| # Copy application code and data cache | |
| COPY src/ src/ | |
| COPY config/ config/ | |
| COPY backend/ backend/ | |
| COPY Data/ Data/ | |
| ENV PYTHONPATH=/app | |
| # Switch to non-root | |
| USER solarwine | |
| # HuggingFace Spaces requires port 7860 | |
| EXPOSE 7860 | |
| HEALTHCHECK --interval=30s --timeout=5s --retries=3 \ | |
| CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:7860/api/health')" || exit 1 | |
| CMD ["uvicorn", "backend.api.main:app", "--host", "0.0.0.0", "--port", "7860"] | |