FROM python:3.11-slim ENV PYTHONDONTWRITEBYTECODE=1 \ PYTHONUNBUFFERED=1 \ PIP_NO_CACHE_DIR=1 WORKDIR /app # System deps for lightgbm / xgboost wheels RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ libgomp1 \ curl \ && rm -rf /var/lib/apt/lists/* COPY requirements.txt . RUN pip install --upgrade pip && pip install -r requirements.txt COPY . . # Pre-train a baseline model so the first request works even without a manual /train-model call. # Comment out if you want a cold start. RUN python -m app.training.train || echo "Initial training failed; will fall back to physics." EXPOSE 8000 HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \ CMD curl -fsS http://localhost:8000/api/v1/health || exit 1 CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]