FROM python:3.11-slim WORKDIR /app COPY requirements.txt . # 🟢 Add this block BEFORE pip install: RUN apt-get update && apt-get install -y libgomp1 RUN pip install --no-cache-dir -r requirements.txt COPY main.py . COPY hidden_logic/ ./hidden_logic/ # Create shutdown script RUN echo '#!/bin/bash\nsleep 300\nkill -15 1' > /app/shutdown.sh && chmod +x /app/shutdown.sh EXPOSE 7860 # Use 8 cores for numpy/scipy/pandas (OpenMP, MKL, OpenBLAS, NumExpr) ENV OMP_NUM_THREADS=4 ENV MKL_NUM_THREADS=4 ENV OPENBLAS_NUM_THREADS=4 ENV NUMEXPR_NUM_THREADS=4 # Start both the API and shutdown script. # Keep a single worker because fit/forecast state is in-memory per process. CMD ["/bin/bash", "-c", "/app/shutdown.sh & uvicorn main:app --host 0.0.0.0 --port 7860 --workers 1"]