ubix commited on
Commit
6dd8755
Β·
verified Β·
1 Parent(s): fdde6d5

Upload Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +97 -0
Dockerfile ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:22-bookworm-slim
2
+
3
+ # ── System deps ───────────────────────────────────────────────────────────────
4
+ # better-sqlite3 β†’ needs python3 + make + g++ for node-gyp
5
+ # python3-pip β†’ mi-db skill runtime deps
6
+ # sqlite3 CLI β†’ entrypoint DB inspection + schema init
7
+ RUN apt-get update && \
8
+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
9
+ ca-certificates curl git \
10
+ python3 python3-pip \
11
+ make g++ sqlite3 && \
12
+ apt-get clean && rm -rf /var/lib/apt/lists/*
13
+
14
+ # ── Python deps for mi-db skill ───────────────────────────────────────────────
15
+ # sentence-transformers β†’ vector embeddings (KNN search)
16
+ # scikit-learn β†’ DBSCAN topic clustering
17
+ # sqlite-vec β†’ vec0 extension for SQLite KNN
18
+ # numpy β†’ required by both above
19
+ #
20
+ # NOTE: If image size is a concern, remove sentence-transformers + scikit-learn.
21
+ # The mi-db skill falls back gracefully to FTS5 keyword search without them.
22
+ # sqlite-vec alone (~1 MB) is always worth keeping.
23
+ RUN pip3 install --break-system-packages --no-cache-dir \
24
+ sqlite-vec \
25
+ sentence-transformers \
26
+ scikit-learn \
27
+ numpy 2>/dev/null || \
28
+ pip3 install --break-system-packages --no-cache-dir \
29
+ scikit-learn numpy && \
30
+ echo "[build] Python deps installed"
31
+
32
+ # ── Build clawd API ───────────────────────────────────────────────────────────
33
+ # Your repo layout: clawd-api/clawd/ β†’ COPY clawd/ . β†’ /app
34
+ WORKDIR /app
35
+ COPY clawd/ .
36
+
37
+ # Install Node deps + ensure better-sqlite3 is compiled for Node 22
38
+ # --build-from-source forces recompile against exact ABI in this image
39
+ RUN npm install && \
40
+ npm list better-sqlite3 --depth=0 2>/dev/null | grep -q better-sqlite3 || \
41
+ npm install --no-save --build-from-source better-sqlite3
42
+
43
+ RUN npx tsc
44
+
45
+ # Fail fast if better-sqlite3 native addon did not compile
46
+ RUN node -e "require('better-sqlite3'); console.log('[build] better-sqlite3 OK')" || \
47
+ (echo '[build] ERROR: better-sqlite3 failed to load.' && exit 1)
48
+
49
+ # ── Build clawd-ui ────────────────────────────────────────────────────────────
50
+ WORKDIR /ui
51
+ COPY clawd-ui/ .
52
+
53
+ # VITE_CLAWD_API_BASE baked at build time via HF Space Variables (not Secrets)
54
+ ARG VITE_CLAWD_API_BASE=
55
+ ENV VITE_CLAWD_API_BASE=$VITE_CLAWD_API_BASE
56
+
57
+ # VITE_CLAWD_API_TOKEN deliberately NOT baked β€” token enforced server-side
58
+ ARG VITE_CLAWD_API_TOKEN=
59
+ ENV VITE_CLAWD_API_TOKEN=$VITE_CLAWD_API_TOKEN
60
+
61
+ RUN npm install && npm run build
62
+
63
+ # ── Back to /app for runtime ──────────────────────────────────────────────────
64
+ WORKDIR /app
65
+ ENV NODE_ENV=production
66
+ ENV CLAWD_STATIC_DIR=/ui/dist
67
+ EXPOSE 7860
68
+
69
+ # ── Bake models.json (merges into live on every boot) ─────────────────────────
70
+ RUN mkdir -p /app/config
71
+ COPY clawd/config/models.json /app/config/models.json
72
+
73
+ # ── Bake market-intelligence team into image ──────────────────────────────────
74
+ # Source: clawd-api/clawd/teams/market-intelligence/
75
+ # Dest: /app/teams/market-intelligence/
76
+ # The entrypoint copies this to $CLAWD_DIR/teams/market-intelligence/ on first
77
+ # boot only (guarded), so user runtime changes are preserved across redeploys.
78
+ COPY clawd/teams/market-intelligence /app/teams/market-intelligence
79
+
80
+ # ── Bake global mi-db skill into image ────────────────────────────────────────
81
+ # Source: clawd-api/clawd/skills/mi-db/
82
+ # Dest: /app/skills/mi-db/
83
+ # Contains: SKILL.md db.py setup_db.py
84
+ COPY clawd/skills/mi-db /app/skills/mi-db
85
+
86
+ # ── Canonical entrypoint (single source of truth) ─────────────────────────────
87
+ COPY entrypoint.sh /app/entrypoint.sh
88
+ RUN chmod +x /app/entrypoint.sh
89
+
90
+ # ── Permissions ───────────────────────────────────────────────────────────────
91
+ # /data is HF-mounted at runtime β€” cannot chown at build time
92
+ RUN chown -R node:node /app /ui && \
93
+ mkdir -p /home/user && \
94
+ chown -R node:node /home/user
95
+
96
+ USER node
97
+ ENTRYPOINT ["/app/entrypoint.sh"]