8900 commited on
Update Dockerfile
Browse files- 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 |
-
|
| 7 |
-
ARG OPENCLAW_VERSION=latest
|
| 8 |
-
FROM ghcr.io/openclaw/openclaw:${OPENCLAW_VERSION} AS openclaw
|
| 9 |
|
| 10 |
-
#
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
| 13 |
|
| 14 |
-
#
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 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 |
-
|
| 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 |
-
|
| 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"]
|
|
|