Subsequently commited on
Commit
88d8c8c
Β·
verified Β·
1 Parent(s): c87df3d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +35 -36
Dockerfile CHANGED
@@ -1,42 +1,41 @@
1
- FROM ghcr.io/openclaw/openclaw:latest
 
 
 
 
2
 
3
- USER root
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
- # ----------------------------------------------------------------
6
- # Remove Baileys (WhatsApp automation lib) from the base image.
7
- # OpenClaw bundles it for WhatsApp channel support, but HF policy
8
- # prohibits third-party messaging automation. Purge it completely.
9
- # ----------------------------------------------------------------
10
- RUN find /app /usr/local/lib /root -type d \( \
11
- -name "baileys" \
12
- -o -name "@whiskeysockets" \
13
- -o -name "whatsapp-web*" \
14
- \) -exec rm -rf {} + 2>/dev/null || true && \
15
- find /app /usr/local/lib /root -name "package.json" ! -path "*/\.*" \
16
- -exec sh -c ' \
17
- node -e " \
18
- var fs=require(\"fs\"); \
19
- var p=process.argv[1]; \
20
- try { \
21
- var j=JSON.parse(fs.readFileSync(p,\"utf-8\")); \
22
- var changed=false; \
23
- [\"dependencies\",\"devDependencies\",\"optionalDependencies\"].forEach(function(k){ \
24
- if(!j[k]) return; \
25
- [\"baileys\",\"@whiskeysockets/baileys\",\"@adiwajshing/baileys\"].forEach(function(b){ \
26
- if(j[k][b]){ delete j[k][b]; changed=true; \
27
- console.log(\"[baileys-purge] Removed \"+b+\" from \"+p); } \
28
- }); \
29
- }); \
30
- if(changed) fs.writeFileSync(p,JSON.stringify(j,null,2)); \
31
- } catch(e){} \
32
- " "$1" \
33
- ' _ {} \; 2>/dev/null || true
34
 
35
- # Copy Space repo files into container
36
- COPY openclaw.json /app/openclaw-template.json
 
 
 
37
  COPY setup-hf-config.mjs /app/spaces/huggingface/setup-hf-config.mjs
38
- COPY entrypoint.sh /app/entrypoint.sh
39
- COPY security-check.sh /app/security-check.sh
 
 
 
 
 
40
 
41
  # PATCH: suppress meta.lastTouchedAt from triggering gateway restarts
42
  RUN node -e " \
@@ -79,7 +78,7 @@ RUN node -e " \
79
  console.log('[patch] Done. ' + patched + '/' + bundles.length + ' file(s) patched'); \
80
  " || echo "[patch] Non-fatal: patch step failed"
81
 
82
- RUN chmod +x /app/entrypoint.sh /app/security-check.sh && \
83
  mkdir -p /data && chmod 777 /data && \
84
  mkdir -p /home/user && chmod 777 /home/user
85
 
 
1
+ # ════════════════════════════════════════════════════════════════
2
+ # OpenClaw for HuggingFace Spaces β€” Multi-stage build
3
+ # Stage 1: extract OpenClaw binary from official image
4
+ # Stage 2: fresh node:22-slim base (no Baileys, no WhatsApp libs)
5
+ # ════════════════════════════════════════════════════════════════
6
 
7
+ # ── Stage 1: Pull pre-built OpenClaw ──
8
+ FROM ghcr.io/openclaw/openclaw:latest AS openclaw
9
+
10
+ # ── Stage 2: Clean runtime β€” Baileys never enters this layer ──
11
+ FROM node:22-slim
12
+
13
+ # Install system dependencies (nginx for reverse proxy)
14
+ RUN apt-get update && apt-get install -y \
15
+ nginx \
16
+ git \
17
+ ca-certificates \
18
+ curl \
19
+ netcat-openbsd \
20
+ --no-install-recommends && \
21
+ rm -rf /var/lib/apt/lists/*
22
 
23
+ # Copy OpenClaw app from Stage 1 (binary/app only, no npm install needed)
24
+ COPY --from=openclaw /app /app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
 
26
+ # Symlink openclaw CLI
27
+ RUN ln -sf /app/openclaw.mjs /usr/local/bin/openclaw 2>/dev/null || true
28
+
29
+ # Copy Space repo files
30
+ COPY openclaw.json /app/openclaw-template.json
31
  COPY setup-hf-config.mjs /app/spaces/huggingface/setup-hf-config.mjs
32
+ COPY entrypoint.sh /app/entrypoint.sh
33
+ COPY security-check.sh /app/security-check.sh
34
+ COPY nginx.conf /etc/nginx/conf.d/default.conf
35
+ COPY start.sh /app/start.sh
36
+
37
+ # Remove default nginx site
38
+ RUN rm -f /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default
39
 
40
  # PATCH: suppress meta.lastTouchedAt from triggering gateway restarts
41
  RUN node -e " \
 
78
  console.log('[patch] Done. ' + patched + '/' + bundles.length + ' file(s) patched'); \
79
  " || echo "[patch] Non-fatal: patch step failed"
80
 
81
+ RUN chmod +x /app/entrypoint.sh /app/security-check.sh /app/start.sh && \
82
  mkdir -p /data && chmod 777 /data && \
83
  mkdir -p /home/user && chmod 777 /home/user
84