Upload Dockerfile
Browse files- Dockerfile +14 -9
Dockerfile
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
|
|
| 1 |
# DEPTH Risk Map -- Hugging Face Docker Space
|
| 2 |
# Base ships R + sf/GDAL/GEOS/PROJ (the slowest deps to build).
|
|
|
|
| 3 |
FROM rocker/geospatial:4.4
|
| 4 |
|
| 5 |
# DuckDB lives on the edgarodriguez/depth_alpha dataset (public); baked in at
|
| 6 |
# build. Override with: docker build --build-arg DDB_URL=... -t depth-hf .
|
| 7 |
ARG DDB_URL=https://huggingface.co/datasets/edgarodriguez/depth_alpha/resolve/main/depth_mexico.duckdb
|
| 8 |
|
| 9 |
-
# RAG index (corpus
|
| 10 |
-
#
|
| 11 |
-
#
|
| 12 |
-
# secret
|
| 13 |
-
#
|
|
|
|
|
|
|
| 14 |
ARG RAG_URL=https://huggingface.co/datasets/edgarodriguez/depth_rag/resolve/main/rag_chunks.parquet
|
| 15 |
|
| 16 |
# Small local models served in-container by Ollama (no external inference).
|
|
@@ -56,15 +60,16 @@ RUN curl -fL "${DDB_URL}" -o /app/depth_mexico.duckdb \
|
|
| 56 |
&& test -s /app/depth_mexico.duckdb \
|
| 57 |
&& ls -lh /app/depth_mexico.duckdb
|
| 58 |
|
| 59 |
-
# Bake the private RAG index (best-effort; never fails
|
|
|
|
| 60 |
RUN --mount=type=secret,id=hf_token \
|
| 61 |
-
if [ -
|
| 62 |
( curl -fL -H "Authorization: Bearer $(cat /run/secrets/hf_token)" "${RAG_URL}" -o /app/rag_chunks.parquet \
|
| 63 |
&& test -s /app/rag_chunks.parquet \
|
| 64 |
&& echo "[build] RAG index baked: $(ls -lh /app/rag_chunks.parquet | awk '{print $5}')" ) \
|
| 65 |
-
|| echo "[build] RAG fetch failed
|
| 66 |
else \
|
| 67 |
-
echo "[build] no hf_token secret -> assistant offline until rag_chunks.parquet is provided"; \
|
| 68 |
fi
|
| 69 |
|
| 70 |
# HF Spaces runs the container as a non-root user -- make /app world-readable,
|
|
|
|
| 1 |
+
# syntax=docker/dockerfile:1
|
| 2 |
# DEPTH Risk Map -- Hugging Face Docker Space
|
| 3 |
# Base ships R + sf/GDAL/GEOS/PROJ (the slowest deps to build).
|
| 4 |
+
# The `# syntax` line above enables BuildKit features (RUN --mount=type=secret).
|
| 5 |
FROM rocker/geospatial:4.4
|
| 6 |
|
| 7 |
# DuckDB lives on the edgarodriguez/depth_alpha dataset (public); baked in at
|
| 8 |
# build. Override with: docker build --build-arg DDB_URL=... -t depth-hf .
|
| 9 |
ARG DDB_URL=https://huggingface.co/datasets/edgarodriguez/depth_alpha/resolve/main/depth_mexico.duckdb
|
| 10 |
|
| 11 |
+
# RAG index (corpus chunks + local embeddings) for the AI assistant. The corpus
|
| 12 |
+
# is copyright-derived, so it lives on a PRIVATE dataset and is pulled with a
|
| 13 |
+
# BuildKit secret (id=hf_token) -- never from a public source. Configure the
|
| 14 |
+
# secret in the Space: Settings -> Variables and secrets -> New secret, name it
|
| 15 |
+
# exactly `hf_token`, value = an HF access token with read access to the dataset.
|
| 16 |
+
# If the secret/dataset are absent the build still succeeds; the assistant just
|
| 17 |
+
# stays offline until rag_chunks.parquet is present.
|
| 18 |
ARG RAG_URL=https://huggingface.co/datasets/edgarodriguez/depth_rag/resolve/main/rag_chunks.parquet
|
| 19 |
|
| 20 |
# Small local models served in-container by Ollama (no external inference).
|
|
|
|
| 60 |
&& test -s /app/depth_mexico.duckdb \
|
| 61 |
&& ls -lh /app/depth_mexico.duckdb
|
| 62 |
|
| 63 |
+
# Bake the private RAG index via the hf_token secret (best-effort; never fails
|
| 64 |
+
# the build). The secret is mounted only for this RUN, at /run/secrets/hf_token.
|
| 65 |
RUN --mount=type=secret,id=hf_token \
|
| 66 |
+
if [ -s /run/secrets/hf_token ]; then \
|
| 67 |
( curl -fL -H "Authorization: Bearer $(cat /run/secrets/hf_token)" "${RAG_URL}" -o /app/rag_chunks.parquet \
|
| 68 |
&& test -s /app/rag_chunks.parquet \
|
| 69 |
&& echo "[build] RAG index baked: $(ls -lh /app/rag_chunks.parquet | awk '{print $5}')" ) \
|
| 70 |
+
|| echo "[build] RAG fetch failed (token lacks access or URL wrong) -> assistant offline" ; \
|
| 71 |
else \
|
| 72 |
+
echo "[build] no hf_token secret -> assistant offline until rag_chunks.parquet is provided" ; \
|
| 73 |
fi
|
| 74 |
|
| 75 |
# HF Spaces runs the container as a non-root user -- make /app world-readable,
|