-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (34 loc) · 1.59 KB
/
Copy pathDockerfile
File metadata and controls
42 lines (34 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Build context is this directory:
#
# docker build -t clair-algorithm .
#
# The image bundles torch (CPU wheel) + sentence-transformers and bakes the
# bge-m3 weights at build time, so a container boots without downloading ~2.2GB
# and needs no network access to Hugging Face at runtime. That makes the image
# large (~3GB) and the host RAM-heavy (the model wants several GB), which is a
# fair trade for a single long-lived process that should start fast offline.
FROM python:3.12-slim
WORKDIR /app
ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1 \
HF_HOME=/opt/hf \
HF_HUB_DISABLE_TELEMETRY=1 \
EMBED_BACKEND=local
# CPU-only torch first, from PyTorch's CPU index — otherwise
# sentence-transformers pulls the default CUDA build and multi-GB of GPU
# libraries that a CPU host can't use.
RUN pip install torch --index-url https://download.pytorch.org/whl/cpu
# Then the rest (sentence-transformers finds torch already satisfied).
COPY requirements.txt ./
RUN pip install -r requirements.txt
# Bake the weights into the image's Hugging Face cache (HF_HOME).
RUN python -c "from sentence_transformers import SentenceTransformer; SentenceTransformer('BAAI/bge-m3')"
# With the weights cached, pin the runtime fully offline. Otherwise
# sentence-transformers HEAD-checks huggingface.co for model updates on every
# load; where egress to that host is slow or blocked, each check burns its full
# timeout per file and turns a fast local load into a multi-minute startup. Set
# after the bake, which does need the network.
ENV HF_HUB_OFFLINE=1 \
TRANSFORMERS_OFFLINE=1
COPY . ./
CMD ["python", "main.py"]