FROM python:3.10-slim # System deps for git (to clone Kronos) and a couple of build tools RUN apt-get update && apt-get install -y --no-install-recommends \ git \ build-essential \ && rm -rf /var/lib/apt/lists/* # HF Spaces run as user 1000 RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:${PATH}" WORKDIR /home/user/app # Install Python deps first (better layer caching) COPY --chown=user requirements.txt . RUN pip install --no-cache-dir --user -r requirements.txt # Clone the Kronos repo so we can import its `model` package RUN git clone --depth 1 https://github.com/shiyu-coder/Kronos.git \ /home/user/app/Kronos # Pre-download the model weights at build time so the Space starts fast RUN python -c "\ from huggingface_hub import snapshot_download; \ snapshot_download('NeoQuasar/Kronos-Tokenizer-2k'); \ snapshot_download('NeoQuasar/Kronos-mini'); \ print('Weights cached.')" COPY --chown=user app.py . EXPOSE 7860 CMD ["python", "app.py"]