edgarodriguez commited on
Commit
6aa9c74
·
verified ·
1 Parent(s): 4a06829

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. 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
- ( curl -fL -H "Authorization: Bearer $(cat /run/secrets/hf_token)" "${RAG_URL}" -o /app/rag_chunks.parquet \
74
- && test -s /app/rag_chunks.parquet \
75
- && echo "[build] RAG index baked: $(ls -lh /app/rag_chunks.parquet | awk '{print $5}')" ) \
76
- || echo "[build] RAG fetch failed (token lacks access or URL wrong) -> assistant offline" ; \
 
 
 
 
77
  else \
78
- echo "[build] no hf_token secret -> assistant offline until rag_chunks.parquet is provided" ; \
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,