echo8900 commited on
Commit
058c130
·
verified ·
1 Parent(s): e6a204d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +41 -38
Dockerfile CHANGED
@@ -2,49 +2,52 @@ FROM ghcr.io/openclaw/openclaw:latest
2
 
3
  USER root
4
 
5
- # 只复制当前实际存在的文件
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
- COPY diagnose.sh /app/diagnose.sh # ← Claude 的检测脚本,保留这一行
11
 
12
- # PATCH: fix meta.lastTouchedAt triggering unnecessary gateway restarts
13
- RUN node -e " \
14
- const fs = require('fs'); \
15
- const { execSync } = require('child_process'); \
16
- function findBundles() { \
17
- try { \
18
- const out = execSync('find /app -name \"gateway-cli*.js\" -not -path \"*/node_modules/*\" 2>/dev/null').toString().trim(); \
19
- return out ? out.split('\n').filter(Boolean) : []; \
20
- } catch(e) { return []; } \
21
- } \
22
- const bundles = findBundles(); \
23
- if (bundles.length === 0) { console.log('[patch] No bundle found - skipping'); process.exit(0); } \
24
- let patched = 0; \
25
- bundles.forEach(function(file) { \
26
- let src = fs.readFileSync(file, 'utf-8'); \
27
- if (src.includes('prefix:\"meta\"') || src.includes(\"prefix:'meta'\")) { \
28
- console.log('[patch] Already patched: ' + file); return; \
29
- } \
30
- const patterns = [ \
31
- ['{prefix:\"channels\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"channels\",kind:'], \
32
- ['{prefix:\"update\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"update\",kind:'], \
33
- ['{prefix:\"agents\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"agents\",kind:'] \
34
- ]; \
35
- let applied = false; \
36
- for (let i = 0; i < patterns.length; i++) { \
37
- if (src.includes(patterns[i][0])) { \
38
- src = src.replace(patterns[i][0], patterns[i][1]); \
39
- applied = true; break; \
40
- } \
41
- } \
42
- if (applied) { fs.writeFileSync(file, src, 'utf-8'); \
43
- console.log('[patch] Patched: ' + file); patched++; } \
44
- else { console.log('[patch] Pattern not found: ' + file); \
45
- } \
46
- }); \
47
- console.log('[patch] Done. Patched: ' + patched + '/' + bundles.length); \
 
 
 
48
  " || echo "[patch] Non-fatal: patch step failed"
49
 
50
  RUN chmod +x /app/entrypoint.sh /app/security-check.sh /app/diagnose.sh && \
 
2
 
3
  USER root
4
 
5
+ # 基础文件复制
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
+ COPY diagnose.sh /app/diagnose.sh
11
 
12
+ # 修复 meta.lastTouchedAt 导致频繁重启的问题
13
+ RUN node -e "
14
+ const fs = require('fs');
15
+ const { execSync } = require('child_process');
16
+ function findBundles() {
17
+ try {
18
+ const out = execSync('find /app -name \"gateway-cli*.js\" -not -path \"*/node_modules/*\" 2>/dev/null').toString().trim();
19
+ return out ? out.split('\n').filter(Boolean) : [];
20
+ } catch(e) { return []; }
21
+ }
22
+ const bundles = findBundles();
23
+ if (bundles.length === 0) { console.log('[patch] No bundle found - skipping'); process.exit(0); }
24
+ let patched = 0;
25
+ bundles.forEach(function(file) {
26
+ let src = fs.readFileSync(file, 'utf-8');
27
+ if (src.includes('prefix:\"meta\"') || src.includes(\"prefix:'meta'\")) {
28
+ console.log('[patch] Already patched: ' + file); return;
29
+ }
30
+ const patterns = [
31
+ ['{prefix:\"channels\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"channels\",kind:'],
32
+ ['{prefix:\"update\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"update\",kind:'],
33
+ ['{prefix:\"agents\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"agents\",kind:']
34
+ ];
35
+ let applied = false;
36
+ for (let i = 0; i < patterns.length; i++) {
37
+ if (src.includes(patterns[i][0])) {
38
+ src = src.replace(patterns[i][0], patterns[i][1]);
39
+ applied = true; break;
40
+ }
41
+ }
42
+ if (applied) {
43
+ fs.writeFileSync(file, src, 'utf-8');
44
+ console.log('[patch] Patched: ' + file);
45
+ patched++;
46
+ } else {
47
+ console.log('[patch] Pattern not found: ' + file);
48
+ }
49
+ });
50
+ console.log('[patch] Done. Patched: ' + patched + '/' + bundles.length);
51
  " || echo "[patch] Non-fatal: patch step failed"
52
 
53
  RUN chmod +x /app/entrypoint.sh /app/security-check.sh /app/diagnose.sh && \