8900 commited on
Commit
403fe23
·
verified ·
1 Parent(s): 722bc6a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +22 -36
Dockerfile CHANGED
@@ -2,70 +2,55 @@ FROM ghcr.io/openclaw/openclaw:latest
2
 
3
  USER root
4
 
5
- COPY setup-hf-config.mjs /app/spaces/huggingface/setup-hf-config.mjs
6
- COPY entrypoint.sh /app/entrypoint.sh
7
- COPY hf-sync-manager.mjs /app/hf-sync-manager.mjs
8
- COPY security-check.sh /app/security-check.sh
 
 
9
 
10
- # ============================================================
11
  # PATCH: fix meta.lastTouchedAt triggering unnecessary gateway restarts
12
- # See: https://github.com/openclaw/openclaw/issues/11744
13
- #
14
- # meta.lastTouchedAt is updated on every config write but is not in
15
- # BASE_RELOAD_RULES, so matchRule() returns null and triggers a full
16
- # gateway restart (SIGUSR1) on every config save.
17
- #
18
- # Fix: inject {prefix:"meta",kind:"none"} into BASE_RELOAD_RULES
19
- # so meta.* changes are classified as no-ops.
20
- # ============================================================
21
  RUN node -e " \
22
  const fs = require('fs'); \
23
- const path = require('path'); \
24
  const { execSync } = require('child_process'); \
25
- \
26
  function findBundles() { \
27
  try { \
28
  const out = execSync('find /app -name \"gateway-cli*.js\" -not -path \"*/node_modules/*\" 2>/dev/null').toString().trim(); \
29
  return out ? out.split('\n').filter(Boolean) : []; \
30
  } catch(e) { return []; } \
31
  } \
32
- \
33
  const bundles = findBundles(); \
34
- if (bundles.length === 0) { \
35
- console.log('[patch] No gateway-cli bundle found - skipping'); \
36
- process.exit(0); \
37
- } \
38
- \
39
  let patched = 0; \
40
  bundles.forEach(function(file) { \
41
  let src = fs.readFileSync(file, 'utf-8'); \
42
  if (src.includes('prefix:\"meta\"') || src.includes(\"prefix:'meta'\")) { \
43
- console.log('[patch] Already patched: ' + file); \
44
- return; \
45
  } \
46
  const patterns = [ \
47
  ['{prefix:\"channels\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"channels\",kind:'], \
48
- ['{prefix:\"update\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"update\",kind:'], \
49
- ['{prefix:\"agents\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"agents\",kind:'] \
50
  ]; \
51
  let applied = false; \
52
  for (let i = 0; i < patterns.length; i++) { \
53
  if (src.includes(patterns[i][0])) { \
54
  src = src.replace(patterns[i][0], patterns[i][1]); \
55
- applied = true; \
56
- break; \
57
  } \
58
  } \
59
- if (applied) { \
60
- fs.writeFileSync(file, src, 'utf-8'); \
61
- console.log('[patch] Patched: ' + file); \
62
- patched++; \
63
- } else { \
64
- console.log('[patch] Pattern not found in: ' + file + ' (may need manual check)'); \
65
  } \
66
  }); \
67
- console.log('[patch] Done. Files patched: ' + patched + '/' + bundles.length); \
68
- " || echo "[patch] Patch step failed (non-fatal, continuing build)"
69
 
70
  RUN chmod +x /app/entrypoint.sh \
71
  /app/security-check.sh && \
@@ -74,6 +59,7 @@ RUN chmod +x /app/entrypoint.sh \
74
  chown node:node /app/entrypoint.sh \
75
  /app/hf-sync-manager.mjs \
76
  /app/security-check.sh \
 
77
  /app/spaces/huggingface/setup-hf-config.mjs
78
 
79
  USER node
 
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 && \
 
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