reflections-encoder / Dockerfile
system's picture
system HF Staff
deploy: sync encoder from 736c3e5
56749a4 verified
Raw
History Blame Contribute Delete
942 Bytes
FROM python:3.12-slim
# HF Spaces runs containers as a non-root user; create one and give it a writable
# HF cache so the baked-in model is readable at runtime.
RUN useradd -m -u 1000 user
ENV HF_HOME=/home/user/.cache/huggingface \
PYTHONUNBUFFERED=1
WORKDIR /home/user/app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
ARG SIGLIP_MODEL_ID=onnx-community/siglip2-base-patch16-256-ONNX
ENV SIGLIP_MODEL_ID=${SIGLIP_MODEL_ID}
COPY text_encoder.py app.py ./
USER user
# Bake the 283 MB text tower + tokenizer into the image so a post-sleep wake
# never re-downloads from HuggingFace.
RUN python -c "import os; \
from huggingface_hub import hf_hub_download; \
from transformers import AutoTokenizer; \
m = os.environ['SIGLIP_MODEL_ID']; \
hf_hub_download(m, 'onnx/text_model_quantized.onnx'); \
AutoTokenizer.from_pretrained(m)"
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]