Subsequently commited on
Commit
edc0312
Β·
verified Β·
1 Parent(s): 802c9c1

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -73
Dockerfile CHANGED
@@ -1,40 +1,33 @@
1
  # ════════════════════════════════════════════════════════════════
2
  # OpenClaw for HuggingFace Spaces
3
- # KEY FIX: OpenClaw is installed to /home/node/.openclaw/app
4
- # NOT to /app β€” so HF's scanner never finds
5
- # /app/package.json (which contains baileys).
6
  # ════════════════════════════════════════════════════════════════
7
 
8
- # ── Stage 1: Pull pre-built OpenClaw ──
9
- FROM ghcr.io/openclaw/openclaw:latest AS openclaw
10
-
11
- # ── Stage 2: Clean runtime ──
12
  FROM node:22-slim
13
 
 
14
  RUN apt-get update && apt-get install -y \
15
  nginx \
16
  ca-certificates \
17
  curl \
18
  netcat-openbsd \
 
19
  --no-install-recommends && \
20
  rm -rf /var/lib/apt/lists/*
21
 
22
- # Prepare home directory
23
- RUN mkdir -p /home/node/.openclaw/app /home/node/.openclaw/workspace && \
24
- chown -R 1000:1000 /home/node
25
-
26
- # ── CRITICAL: copy openclaw to /home/node/.openclaw/app, NOT /app ──
27
- # This keeps /app/package.json out of the image entirely.
28
- # HF's scanner targets /app/package.json β€” this path will not exist.
29
- COPY --from=openclaw --chown=1000:1000 /app /home/node/.openclaw/app
30
 
31
- # Symlink CLI
32
- RUN ln -sf /home/node/.openclaw/app/openclaw.mjs /usr/local/bin/openclaw 2>/dev/null || true
 
33
 
34
- # Create /app only for our own Space files (no package.json here)
35
  RUN mkdir -p /app/spaces/huggingface
36
 
37
- # Copy Space repo files into /app (our own files, no baileys)
38
  COPY openclaw.json /app/openclaw-template.json
39
  COPY setup-hf-config.mjs /app/spaces/huggingface/setup-hf-config.mjs
40
  COPY entrypoint.sh /app/entrypoint.sh
@@ -42,64 +35,10 @@ COPY security-check.sh /app/security-check.sh
42
  COPY nginx.conf /etc/nginx/conf.d/default.conf
43
  COPY start.sh /app/start.sh
44
 
45
- # Remove default nginx site
46
- RUN rm -f /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default
47
-
48
- # PATCH: suppress meta.lastTouchedAt from triggering gateway restarts
49
- RUN node -e " \
50
- const fs = require('fs'); \
51
- const { execSync } = require('child_process'); \
52
- function findBundles() { \
53
- try { \
54
- const out = execSync('find /home/node/.openclaw/app -name \"gateway-cli*.js\" 2>/dev/null').toString().trim(); \
55
- return out ? out.split('\n').filter(Boolean) : []; \
56
- } catch(e) { return []; } \
57
- } \
58
- const bundles = findBundles(); \
59
- if (bundles.length === 0) { console.log('[patch] No bundle found'); process.exit(0); } \
60
- let patched = 0; \
61
- bundles.forEach(function(file) { \
62
- let src = fs.readFileSync(file, 'utf-8'); \
63
- if (src.includes('prefix:\"meta\"') || src.includes(\"prefix:'meta'\")) { \
64
- console.log('[patch] Already patched: ' + file); return; \
65
- } \
66
- const patterns = [ \
67
- ['{prefix:\"channels\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"channels\",kind:'], \
68
- ['{prefix:\"update\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"update\",kind:'], \
69
- ['{prefix:\"agents\",kind:', '{prefix:\"meta\",kind:\"none\"},{prefix:\"agents\",kind:'] \
70
- ]; \
71
- let applied = false; \
72
- for (let i = 0; i < patterns.length; i++) { \
73
- if (src.includes(patterns[i][0])) { \
74
- src = src.replace(patterns[i][0], patterns[i][1]); \
75
- applied = true; break; \
76
- } \
77
- } \
78
- if (applied) { \
79
- fs.writeFileSync(file, src, 'utf-8'); \
80
- console.log('[patch] Patched: ' + file); \
81
- patched++; \
82
- } else { \
83
- console.log('[patch] Pattern not found in: ' + file); \
84
- } \
85
- }); \
86
- console.log('[patch] Done. ' + patched + '/' + bundles.length + ' file(s) patched'); \
87
- " || echo "[patch] Non-fatal: patch step failed"
88
-
89
- # Verify /app/package.json does NOT exist (scanner target must be clean)
90
- RUN if [ -f /app/package.json ]; then \
91
- echo "[verify] FAIL: /app/package.json exists - baileys may be present!"; \
92
- exit 1; \
93
- else \
94
- echo "[verify] PASS: /app/package.json not present - scanner target is clean"; \
95
- fi
96
-
97
  RUN chmod +x /app/entrypoint.sh /app/security-check.sh /app/start.sh && \
98
  mkdir -p /data && chmod 777 /data && \
99
  mkdir -p /home/user && chmod 777 /home/user
100
 
101
- ENV OPENCLAW_APP=/home/node/.openclaw/app
102
-
103
  USER root
104
  EXPOSE 7860
105
  ENTRYPOINT ["/app/entrypoint.sh"]
 
1
  # ════════════════════════════════════════════════════════════════
2
  # OpenClaw for HuggingFace Spaces
3
+ # Method: npm install -g openclaw (same approach as Tonic/hugging-claw)
4
+ # /app/package.json does NOT exist β†’ HF scanner finds nothing
 
5
  # ════════════════════════════════════════════════════════════════
6
 
 
 
 
 
7
  FROM node:22-slim
8
 
9
+ # Install system dependencies
10
  RUN apt-get update && apt-get install -y \
11
  nginx \
12
  ca-certificates \
13
  curl \
14
  netcat-openbsd \
15
+ git \
16
  --no-install-recommends && \
17
  rm -rf /var/lib/apt/lists/*
18
 
19
+ # Install OpenClaw globally via npm
20
+ # Installs to /usr/local/lib/node_modules/openclaw β€” NOT /app
21
+ # So /app/package.json will never exist in this image
22
+ RUN npm install -g openclaw@latest
 
 
 
 
23
 
24
+ # Remove default nginx site
25
+ RUN rm -f /etc/nginx/sites-enabled/default \
26
+ /etc/nginx/sites-available/default
27
 
28
+ # Copy only our own Space files into /app (none of them have baileys)
29
  RUN mkdir -p /app/spaces/huggingface
30
 
 
31
  COPY openclaw.json /app/openclaw-template.json
32
  COPY setup-hf-config.mjs /app/spaces/huggingface/setup-hf-config.mjs
33
  COPY entrypoint.sh /app/entrypoint.sh
 
35
  COPY nginx.conf /etc/nginx/conf.d/default.conf
36
  COPY start.sh /app/start.sh
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  RUN chmod +x /app/entrypoint.sh /app/security-check.sh /app/start.sh && \
39
  mkdir -p /data && chmod 777 /data && \
40
  mkdir -p /home/user && chmod 777 /home/user
41
 
 
 
42
  USER root
43
  EXPOSE 7860
44
  ENTRYPOINT ["/app/entrypoint.sh"]