# Hugging Face Docker Space — runs as user 1000, app must listen on 7860. FROM python:3.11-slim RUN useradd -m -u 1000 user USER user ENV HOME=/home/user \ PATH=/home/user/.local/bin:$PATH \ HF_HOME=/home/user/.cache/huggingface WORKDIR /home/user/app COPY --chown=user requirements.txt . RUN pip install --user --no-cache-dir -r requirements.txt COPY --chown=user app.py . # Bake the int8 ONNX model + tokenizer into the image (no cold pull on first # request) and assert it loads, pools to 1024-dim, and emits unit-norm vectors. RUN python -c "\ import numpy as np, onnxruntime as ort; \ from huggingface_hub import hf_hub_download; \ from transformers import AutoTokenizer; \ m='libryo-ai/BAAI-bge-m3-int8'; \ tok=AutoTokenizer.from_pretrained(m); \ sess=ort.InferenceSession(hf_hub_download(m,'model.onnx'),providers=['CPUExecutionProvider']); \ names={i.name for i in sess.get_inputs()}; \ e=tok(['ભાવ સમાચાર','mandi prices'],padding=True,truncation=True,max_length=512,return_tensors='np'); \ f={n:(e[n] if n in e else np.zeros_like(e['input_ids'])) for n in names}; \ h=sess.run(None,f)[0]; \ c=h[:,0]; c=c/np.linalg.norm(c,axis=1,keepdims=True); \ assert c.shape==(2,1024), c.shape; \ assert abs(float(np.linalg.norm(c[0]))-1.0)<1e-3; \ print('model ok', c.shape)" EXPOSE 7860 CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]