Prajith04 commited on
Commit
a2911dd
·
verified ·
1 Parent(s): bc61428

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -67
Dockerfile CHANGED
@@ -1,76 +1,29 @@
1
- # ============================================================
2
- # README.md must exist in the repo root with this YAML block:
3
- # ---
4
- # title: OpenClaw
5
- # emoji: 🐾
6
- # sdk: docker
7
- # app_port: 7860
8
- # ---
9
- # ============================================================
10
 
11
- # Stage 1: Ensure submodule source is available
12
- FROM node:22-bookworm-slim AS source
13
- RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates && rm -rf /var/lib/apt/lists/*
14
- WORKDIR /src
15
- COPY . .
16
- RUN if [ ! -f openclaw/package.json ]; then \
17
- rm -rf openclaw && \
18
- git clone --depth 1 -b affine-extension https://github.com/potnoodledev/openclaw.git openclaw; \
19
- fi
20
 
21
- # Stage 2: Build (full install + compile)
22
- FROM node:22-bookworm AS builder
23
- RUN curl -fsSL https://bun.sh/install | bash
24
- ENV PATH="/root/.bun/bin:${PATH}"
25
- RUN corepack enable
26
- WORKDIR /app
27
- COPY --from=source /src/openclaw/package.json /src/openclaw/pnpm-lock.yaml /src/openclaw/pnpm-workspace.yaml /src/openclaw/.npmrc ./
28
- COPY --from=source /src/openclaw/ui/package.json ./ui/package.json
29
- COPY --from=source /src/openclaw/extensions ./extensions
30
- COPY --from=source /src/openclaw/patches ./patches
31
- COPY --from=source /src/openclaw/scripts ./scripts
32
- RUN pnpm install --frozen-lockfile
33
- COPY --from=source /src/openclaw/ .
34
- RUN pnpm build
35
- ENV OPENCLAW_PREFER_PNPM=1
36
- RUN pnpm ui:build
37
- RUN CI=true pnpm prune --prod
38
-
39
- # Stage 3: Runtime
40
- FROM node:22-bookworm-slim
41
-
42
- RUN apt-get update && apt-get install -y --no-install-recommends git curl ca-certificates && rm -rf /var/lib/apt/lists/*
43
- RUN corepack enable
44
-
45
- # HF Spaces requires UID 1000
46
- #RUN useradd -m -u 1000 user
47
-
48
- WORKDIR /app
49
-
50
- COPY --from=builder /app/dist ./dist
51
- COPY --from=builder /app/openclaw.mjs ./openclaw.mjs
52
- COPY --from=builder /app/node_modules ./node_modules
53
- COPY --from=builder /app/package.json ./package.json
54
- COPY --from=builder /app/pnpm-workspace.yaml ./pnpm-workspace.yaml
55
- COPY --from=builder /app/.npmrc ./.npmrc
56
- COPY --from=builder /app/extensions ./extensions
57
- COPY --from=builder /app/packages ./packages
58
- COPY --from=builder /app/patches ./patches
59
- COPY --from=builder /app/docs ./docs
60
-
61
- COPY --from=source /src/openclaw-config /openclaw-config
62
 
 
 
 
 
63
  ENV NODE_ENV=production
64
- ENV OPENCLAW_PREFER_PNPM=1
65
- # HF Spaces: data persists only in /data (if persistent storage is enabled)
66
- ENV HOME=/home/user
67
 
68
- RUN chown -R user:user /app /openclaw-config
 
 
 
69
 
70
- USER user
71
 
72
  EXPOSE 7860
73
 
74
- # Run the entrypoint script, then start on port 7860 (HF Spaces requirement)
75
- ENTRYPOINT ["/bin/sh", "/openclaw-config/entrypoint.sh"]
76
- CMD ["node", "openclaw.mjs", "gateway", "--allow-unconfigured", "--bind", "0.0.0.0", "--port", "7860"]
 
 
 
1
+ FROM ghcr.io/openclaw/openclaw:latest
 
 
 
 
 
 
 
 
2
 
3
+ # HF Spaces runs as UID 1000 — openclaw's node user already matches this
4
+ USER root
 
 
 
 
 
 
 
5
 
6
+ # Create config dirs with correct ownership
7
+ RUN mkdir -p /home/node/.openclaw /home/node/workspace && \
8
+ chown -R node:node /home/node
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ # HF Spaces requires port 7860
11
+ # We configure openclaw to bind on 7860 instead of 18789
12
+ ENV OPENCLAW_GATEWAY_PORT=7860
13
+ ENV OPENCLAW_GATEWAY_BIND=0.0.0.0
14
  ENV NODE_ENV=production
 
 
 
15
 
16
+ # Bake in your provider config (set these as HF Space Secrets)
17
+ # OPENCLAW_GATEWAY_TOKEN — your access token
18
+ # NVIDIA_NIM_API_KEY — if using NVIDIA NIM
19
+ # MODEL — e.g. stepfun-ai/step-3.5-flash
20
 
21
+ USER node
22
 
23
  EXPOSE 7860
24
 
25
+ # Override the default port the gateway starts on
26
+ CMD ["node", "/app/openclaw.mjs", "gateway", \
27
+ "--allow-unconfigured", \
28
+ "--bind", "0.0.0.0", \
29
+ "--port", "7860"]