8900 commited on
Commit
72abd57
Β·
verified Β·
1 Parent(s): 1d7695e

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +59 -87
Dockerfile CHANGED
@@ -1,95 +1,67 @@
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"]
 
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 security-check.sh /app/security-check.sh
10
 
11
+ # PATCH: fix meta.lastTouchedAt triggering unnecessary gateway restarts
12
+ # Issue: https://github.com/openclaw/openclaw/issues/11744
13
+ # meta.lastTouchedAt is updated on every config write, but it is not in
14
+ # BASE_RELOAD_RULES, so every config save triggers a full gateway restart.
15
+ # Fix: inject {prefix:"meta",kind:"none"} into BASE_RELOAD_RULES.
16
+ RUN node -e " \
17
+ const fs = require('fs'); \
18
+ const { execSync } = require('child_process'); \
19
+ function findBundles() { \
20
+ try { \
21
+ const out = execSync('find /app -name \"gateway-cli*.js\" -not -path \"*/node_modules/*\" 2>/dev/null').toString().trim(); \
22
+ return out ? out.split('\n').filter(Boolean) : []; \
23
+ } catch(e) { return []; } \
24
+ } \
25
+ const bundles = findBundles(); \
26
+ if (bundles.length === 0) { console.log('[patch] No bundle found - skipping'); process.exit(0); } \
27
+ \
28
+ let patched = 0; \
29
+ bundles.forEach(function(file) { \
30
+ let src = fs.readFileSync(file, 'utf-8'); \
31
+ if (src.includes('prefix:\"meta\"') || src.includes(\"prefix:'meta'\")) { \
32
+ console.log('[patch] Already patched: ' + file); return; \
33
+ } \
34
+ const patterns = [ \
35
+ ['{prefix:\"channels\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"channels\",kind:'], \
36
+ ['{prefix:\"update\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"update\",kind:'], \
37
+ ['{prefix:\"agents\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"agents\",kind:'] \
38
+ ]; \
39
+ let applied = false; \
40
+ for (let i = 0; i < patterns.length; i++) { \
41
+ if (src.includes(patterns[i][0])) { \
42
+ src = src.replace(patterns[i][0], patterns[i][1]); \
43
+ applied = true; break; \
44
+ } \
45
+ } \
46
+ if (applied) { fs.writeFileSync(file, src, 'utf-8'); \
47
+ console.log('[patch] Patched: ' + file); patched++; } \
48
+ else { console.log('[patch] Pattern not found: ' + file); \
49
+ } \
50
+ }); \
51
+ console.log('[patch] Done. Patched: ' + patched + '/' + bundles.length); \
52
+ " || echo "[patch] Non-fatal: patch step failed"
53
 
54
+ RUN chmod +x /app/entrypoint.sh \
55
+ /app/security-check.sh && \
56
+ mkdir -p /home/user && \
57
+ chown -R node:node /home/user && \
58
+ chown node:node /app/entrypoint.sh \
59
+ /app/security-check.sh \
60
+ /app/openclaw-template.json \
61
+ /app/spaces/huggingface/setup-hf-config.mjs
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
 
63
  USER node
64
 
65
+ EXPOSE 7860
 
 
 
 
 
 
 
 
66
 
67
+ ENTRYPOINT ["/app/entrypoint.sh"]