Spaces:
Running
Running
Update Dockerfile
Browse files- Dockerfile +8 -6
Dockerfile
CHANGED
|
@@ -1,8 +1,5 @@
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
| 3 |
-
# Declare your environment variables with the ARG directive
|
| 4 |
-
ARG HF_TOKEN
|
| 5 |
-
|
| 6 |
# Install build dependencies for packages such as uvicorn[standard]
|
| 7 |
RUN apt-get update && \
|
| 8 |
apt-get install -y --no-install-recommends build-essential git && \
|
|
@@ -26,9 +23,14 @@ COPY --chown=user requirements.txt .
|
|
| 26 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 27 |
pip install --no-cache-dir -r requirements.txt
|
| 28 |
|
| 29 |
-
# Pre-download the
|
| 30 |
-
#
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
import os
|
| 33 |
from sentence_transformers import SentenceTransformer
|
| 34 |
|
|
|
|
| 1 |
FROM python:3.11-slim
|
| 2 |
|
|
|
|
|
|
|
|
|
|
| 3 |
# Install build dependencies for packages such as uvicorn[standard]
|
| 4 |
RUN apt-get update && \
|
| 5 |
apt-get install -y --no-install-recommends build-essential git && \
|
|
|
|
| 23 |
RUN pip install --no-cache-dir --upgrade pip && \
|
| 24 |
pip install --no-cache-dir -r requirements.txt
|
| 25 |
|
| 26 |
+
# Pre-download the gated embedding model to avoid first-request latency.
|
| 27 |
+
# Requires a Hugging Face token supplied at build-time via --build-arg HF_TOKEN=...
|
| 28 |
+
ARG HF_TOKEN
|
| 29 |
+
RUN if [ -z "$HF_TOKEN" ]; then \
|
| 30 |
+
echo "HF_TOKEN build arg missing. Supply --build-arg HF_TOKEN=hf_xxx when building." >&2; \
|
| 31 |
+
exit 1; \
|
| 32 |
+
fi && \
|
| 33 |
+
HF_TOKEN="$HF_TOKEN" python - <<'PY'
|
| 34 |
import os
|
| 35 |
from sentence_transformers import SentenceTransformer
|
| 36 |
|