zangir commited on
Commit
9bfb8a9
·
verified ·
1 Parent(s): 92ea0a8

rubban space shell · bundle 8313ca77

Browse files
Files changed (1) hide show
  1. Dockerfile +32 -0
Dockerfile ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Rubban — public Space shell. Contains no application code: at build time it downloads the private bundle
2
+ # from the dataset zangir/rubban-bundle using the HF_TOKEN build secret, then serves it behind the sign-in gate.
3
+ FROM python:3.12-slim
4
+
5
+ ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 PIP_NO_CACHE_DIR=1 \
6
+ RUBBAN_DATA_ROOT=/data PORT=7860 BUNDLE_REPO=zangir/rubban-bundle BUNDLE_FILE=rubban-bundle.tar.gz
7
+
8
+ RUN apt-get update && apt-get install -y --no-install-recommends libglib2.0-0 && rm -rf /var/lib/apt/lists/* \
9
+ && useradd -m -u 1000 rubban && mkdir -p /srv /data && chown -R rubban:rubban /srv /data
10
+
11
+ WORKDIR /srv
12
+ RUN pip install "huggingface_hub>=0.25"
13
+
14
+ # cache-buster: changing BUNDLE_REV in the Space variables forces a fresh download
15
+ ARG BUNDLE_REV=main
16
+ RUN --mount=type=secret,id=HF_TOKEN,mode=0444,required=true \
17
+ python - <<'EOF'
18
+ import os, tarfile, pathlib
19
+ from huggingface_hub import hf_hub_download
20
+ token = pathlib.Path("/run/secrets/HF_TOKEN").read_text().strip()
21
+ p = hf_hub_download(repo_id=os.environ["BUNDLE_REPO"], filename=os.environ["BUNDLE_FILE"], repo_type="dataset", token=token, revision=os.environ.get("BUNDLE_REV", "main"))
22
+ with tarfile.open(p) as t:
23
+ t.extractall("/srv", filter="data")
24
+ print("bundle extracted:", sorted(os.listdir("/srv")))
25
+ EOF
26
+ RUN pip install -r /srv/rubban-app/requirements.txt && pip install -e /srv/rubban-core \
27
+ && cp -r /srv/data/. /data/ && chown -R rubban:rubban /srv /data
28
+
29
+ USER rubban
30
+ WORKDIR /srv/rubban-app
31
+ EXPOSE 7860
32
+ CMD ["python", "server.py"]