8900 commited on
Commit
1d7695e
Β·
verified Β·
1 Parent(s): 687158b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +87 -61
Dockerfile CHANGED
@@ -1,69 +1,95 @@
1
- FROM ghcr.io/openclaw/openclaw:latest
 
 
 
2
 
3
- USER root
 
 
4
 
5
- # Copy Space repo files into container
6
- COPY openclaw.json /app/openclaw-template.json
7
- COPY setup-hf-config.mjs /app/spaces/huggingface/setup-hf-config.mjs
8
- COPY entrypoint.sh /app/entrypoint.sh
9
- COPY hf-sync-manager.mjs /app/hf-sync-manager.mjs
10
- COPY security-check.sh /app/security-check.sh
11
 
12
- # PATCH: fix meta.lastTouchedAt triggering unnecessary gateway restarts
13
- # Issue: https://github.com/openclaw/openclaw/issues/11744
14
- # meta.lastTouchedAt is updated on every config write, but it is not in
15
- # BASE_RELOAD_RULES, so every config save triggers a full gateway restart.
16
- # Fix: inject {prefix:"meta",kind:"none"} into BASE_RELOAD_RULES.
17
- RUN node -e " \
18
- const fs = require('fs'); \
19
- const { execSync } = require('child_process'); \
20
- function findBundles() { \
21
- try { \
22
- const out = execSync('find /app -name \"gateway-cli*.js\" -not -path \"*/node_modules/*\" 2>/dev/null').toString().trim(); \
23
- return out ? out.split('\n').filter(Boolean) : []; \
24
- } catch(e) { return []; } \
25
- } \
26
- const bundles = findBundles(); \
27
- if (bundles.length === 0) { console.log('[patch] No bundle found - skipping'); process.exit(0); } \
28
-
29
- let patched = 0; \
30
- bundles.forEach(function(file) { \
31
- let src = fs.readFileSync(file, 'utf-8'); \
32
- if (src.includes('prefix:\"meta\"') || src.includes(\"prefix:'meta'\")) { \
33
- console.log('[patch] Already patched: ' + file); return; \
34
- } \
35
- const patterns = [ \
36
- ['{prefix:\"channels\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"channels\",kind:'], \
37
- ['{prefix:\"update\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"update\",kind:'], \
38
- ['{prefix:\"agents\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"agents\",kind:'] \
39
- ]; \
40
- let applied = false; \
41
- for (let i = 0; i < patterns.length; i++) { \
42
- if (src.includes(patterns[i][0])) { \
43
- src = src.replace(patterns[i][0], patterns[i][1]); \
44
- applied = true; break; \
45
- } \
46
- } \
47
- if (applied) { fs.writeFileSync(file, src, 'utf-8'); \
48
- console.log('[patch] Patched: ' + file); patched++; } \
49
- else { console.log('[patch] Pattern not found: ' + file); \
50
- } \
51
- }); \
52
- console.log('[patch] Done. Patched: ' + patched + '/' + bundles.length); \
53
- " || echo "[patch] Non-fatal: patch step failed"
54
 
55
- RUN chmod +x /app/entrypoint.sh \
56
- /app/security-check.sh && \
57
- mkdir -p /home/user && \
58
- chown -R node:node /home/user && \
59
- chown node:node /app/entrypoint.sh \
60
- /app/hf-sync-manager.mjs \
61
- /app/security-check.sh \
62
- /app/openclaw-template.json \
63
- /app/spaces/huggingface/setup-hf-config.mjs
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
  USER node
66
 
67
- EXPOSE 7860
 
 
 
 
 
 
 
 
68
 
69
- ENTRYPOINT ["/app/entrypoint.sh"]
 
 
1
+ # ════════════════════════════════════════════════════════════════
2
+ # 🦞 HuggingClaw β€” OpenClaw Gateway for HuggingFace Spaces
3
+ # 使用 Storage Buckets δ½œδΈΊζŒδΉ…ε­˜ε‚¨οΌŒδΈε†δΎθ΅– hf-sync-manager
4
+ # ════════════════════════════════════════════════════════════════
5
 
6
+ # ── Stage 1: Pull pre-built OpenClaw ──
7
+ ARG OPENCLAW_VERSION=latest
8
+ FROM ghcr.io/openclaw/openclaw:${OPENCLAW_VERSION} AS openclaw
9
 
10
+ # ── Stage 2: Runtime ──
11
+ FROM node:22-slim
12
+ ARG OPENCLAW_VERSION=latest
 
 
 
13
 
14
+ # Install system dependencies
15
+ RUN apt-get update && apt-get install -y \
16
+ git \
17
+ ca-certificates \
18
+ jq \
19
+ curl \
20
+ python3 \
21
+ python3-pip \
22
+ chromium \
23
+ libnss3 \
24
+ libatk1.0-0 \
25
+ libatk-bridge2.0-0 \
26
+ libdrm2 \
27
+ libgbm1 \
28
+ libxcomposite1 \
29
+ libxdamage1 \
30
+ libxrandr2 \
31
+ libxkbcommon0 \
32
+ libx11-6 \
33
+ libxext6 \
34
+ libxfixes3 \
35
+ libasound2 \
36
+ fonts-dejavu-core \
37
+ fonts-liberation \
38
+ fonts-noto-color-emoji \
39
+ fonts-freefont-ttf \
40
+ fonts-ipafont-gothic \
41
+ fonts-wqy-zenhei \
42
+ xfonts-scalable \
43
+ --no-install-recommends && \
44
+ pip3 install --no-cache-dir --break-system-packages huggingface_hub && \
45
+ rm -rf /var/lib/apt/lists/*
 
 
 
 
 
 
 
 
 
 
46
 
47
+ # Reuse existing node user (UID 1000)
48
+ RUN mkdir -p /home/node/app /home/node/.openclaw && \
49
+ chown -R 1000:1000 /home/node
50
+
51
+ # Copy pre-built OpenClaw
52
+ COPY --from=openclaw --chown=1000:1000 /app /home/node/.openclaw/openclaw-app
53
+
54
+ # Add Playwright in an isolated sidecar
55
+ RUN mkdir -p /home/node/browser-deps && \
56
+ cd /home/node/browser-deps && \
57
+ npm init -y && \
58
+ PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install --omit=dev playwright@1.59.1
59
+
60
+ # Symlink openclaw CLI
61
+ RUN ln -s /home/node/.openclaw/openclaw-app/openclaw.mjs /usr/local/bin/openclaw 2>/dev/null || \
62
+ npm install -g openclaw@${OPENCLAW_VERSION}
63
+
64
+ # Copy HuggingClaw filesοΌˆδΈε†ε€εˆΆ hf-sync-manager.mjsοΌ‰
65
+ COPY --chown=1000:1000 dns-fix.js /opt/dns-fix.js
66
+ COPY --chown=1000:1000 health-server.js /home/node/app/health-server.js
67
+ COPY --chown=1000:1000 iframe-fix.cjs /home/node/app/iframe-fix.cjs
68
+ COPY --chown=1000:1000 start.sh /home/node/app/start.sh
69
+ COPY --chown=1000:1000 wa-guardian.js /home/node/app/wa-guardian.js
70
+ COPY --chown=1000:1000 workspace-sync.py /home/node/app/workspace-sync.py
71
+
72
+ # Copy our optimized files
73
+ COPY --chown=1000:1000 entrypoint.sh /home/node/app/entrypoint.sh
74
+ COPY --chown=1000:1000 security-check.sh /home/node/app/security-check.sh
75
+ COPY --chown=1000:1000 openclaw.json /home/node/app/openclaw-template.json
76
+ COPY --chown=1000:1000 setup-hf-config.mjs /home/node/app/spaces/huggingface/setup-hf-config.mjs
77
+
78
+ RUN chmod +x /home/node/app/entrypoint.sh \
79
+ /home/node/app/security-check.sh \
80
+ /home/node/app/start.sh
81
 
82
  USER node
83
 
84
+ ENV HOME=/home/node \
85
+ OPENCLAW_VERSION=${OPENCLAW_VERSION} \
86
+ PATH=/home/node/.local/bin:/usr/local/bin:$PATH \
87
+ NODE_PATH=/home/node/browser-deps/node_modules \
88
+ NODE_OPTIONS="--require /opt/dns-fix.js"
89
+
90
+ WORKDIR /home/node/app
91
+
92
+ EXPOSE 7861
93
 
94
+ # δ½Ώη”¨ζˆ‘δ»¬δΌ˜εŒ–ηš„ entrypoint
95
+ CMD ["/home/node/app/entrypoint.sh"]