Upload Dockerfile
Browse files- Dockerfile +12 -5
Dockerfile
CHANGED
|
@@ -68,14 +68,21 @@ RUN curl -fL "${DDB_URL}" -o /app/depth_mexico.duckdb \
|
|
| 68 |
|
| 69 |
# Bake the private RAG index via the hf_token secret (best-effort; never fails
|
| 70 |
# the build). The secret is mounted only for this RUN, at /run/secrets/hf_token.
|
|
|
|
|
|
|
|
|
|
| 71 |
RUN --mount=type=secret,id=hf_token \
|
| 72 |
if [ -s /run/secrets/hf_token ]; then \
|
| 73 |
-
(
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
else \
|
| 78 |
-
echo "[build] no hf_token secret -> assistant offline
|
| 79 |
fi
|
| 80 |
|
| 81 |
# HF Spaces runs the container as a non-root user -- make /app world-readable,
|
|
|
|
| 68 |
|
| 69 |
# Bake the private RAG index via the hf_token secret (best-effort; never fails
|
| 70 |
# the build). The secret is mounted only for this RUN, at /run/secrets/hf_token.
|
| 71 |
+
# Reports the HTTP status on failure (401 = bad/expired token, 403 = token has no
|
| 72 |
+
# read access to the dataset, 404 = wrong URL/path) and removes a partial file so
|
| 73 |
+
# the app correctly shows "offline" rather than loading a broken index.
|
| 74 |
RUN --mount=type=secret,id=hf_token \
|
| 75 |
if [ -s /run/secrets/hf_token ]; then \
|
| 76 |
+
code=$(curl -sL -o /app/rag_chunks.parquet -w '%{http_code}' \
|
| 77 |
+
-H "Authorization: Bearer $(cat /run/secrets/hf_token)" "${RAG_URL}"); \
|
| 78 |
+
if [ "$code" = "200" ] && [ -s /app/rag_chunks.parquet ]; then \
|
| 79 |
+
echo "[build] RAG index baked: $(ls -lh /app/rag_chunks.parquet | awk '{print $5}')"; \
|
| 80 |
+
else \
|
| 81 |
+
echo "[build] RAG fetch failed (HTTP $code) -> assistant offline"; \
|
| 82 |
+
rm -f /app/rag_chunks.parquet; \
|
| 83 |
+
fi; \
|
| 84 |
else \
|
| 85 |
+
echo "[build] no hf_token secret found at /run/secrets/hf_token -> assistant offline"; \
|
| 86 |
fi
|
| 87 |
|
| 88 |
# HF Spaces runs the container as a non-root user -- make /app world-readable,
|