FROM python:3.11-slim # System deps for torch/prophet/sklearn RUN apt-get update && apt-get install -y --no-install-recommends \ gcc g++ git libgomp1 \ && rm -rf /var/lib/apt/lists/* WORKDIR /app # Install Python deps (prod-only, no dev/test/observability packages) COPY requirements-prod.txt . RUN pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu RUN pip install --no-cache-dir -r requirements-prod.txt COPY . . # Train ML models at build time so startup is instant. # If yfinance is rate-limited during build, training is skipped gracefully # and the entrypoint will retry at runtime (fallback). RUN python build_train.py || true # HF Spaces requires port 7860 ENV PORT=7860 EXPOSE 7860 COPY docker-entrypoint.sh /docker-entrypoint.sh RUN chmod +x /docker-entrypoint.sh ENTRYPOINT ["/docker-entrypoint.sh"]