Cemez83's picture
Deploy forecast-service to Hugging Face Space
bfef05d
Raw
History Blame Contribute Delete
1.11 kB
# forecast-service — TimesFM 2.x + Chronos-2 ensemble API.
# Builds a container any host can run (Hugging Face Spaces / Render / Railway / Fly / a VM),
# so the Vercel app can reach it via FORECAST_URL.
#
# First boot downloads ~2GB of model weights from HuggingFace into HF_HOME (expected, once).
# Binds 0.0.0.0 (FORECAST_HOST) so the host can route to it; honours the host's $PORT
# (Render/Railway/Fly inject one) and otherwise serves on 8008.
FROM python:3.12-slim
# build-essential for any source-built wheels; libgomp1 for torch; git in case a dep needs it.
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential git libgomp1 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Install deps first so Docker caches this layer across code changes.
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
ENV FORECAST_HOST=0.0.0.0 \
HF_HOME=/app/.hf_cache \
PYTHONUNBUFFERED=1
EXPOSE 8008
# ${PORT:-8008}: use the platform-injected port if present, else 8008.
CMD ["sh", "-c", "FORECAST_PORT=${PORT:-8008} python main.py"]