8900 commited on
Commit
b2e4535
·
verified ·
1 Parent(s): a7e0ef5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +35 -24
Dockerfile CHANGED
@@ -1,33 +1,44 @@
1
- FROM node:22
2
 
3
- # 系统依赖
4
- RUN apt-get update && apt-get install -y git curl && rm -rf /var/lib/apt/lists/*
5
 
6
- # 安装 Bun
7
- RUN curl -fsSL https://bun.sh/install | bash
 
 
8
  ENV PATH="/root/.bun/bin:${PATH}"
9
-
10
- WORKDIR /app
11
-
12
- # 克隆 OpenClaw
13
- RUN git clone https://github.com/Josephrp/openclaw.git .
14
-
15
- # 启用 pnpm
16
  RUN corepack enable
17
 
18
- # 安装依赖并 build(只在镜像构建阶段)
19
- RUN pnpm install
20
- RUN pnpm build
21
- RUN pnpm ui:build
22
 
23
- # 复制生产级配置脚本
24
- COPY setup-hf-config.mjs /setup-hf-config.mjs
 
 
 
25
 
 
 
26
  EXPOSE 7860
27
 
28
- # 启动命令,修复 bind 问题 + 配置覆盖 + 允许未配置
29
- CMD node /setup-hf-config.mjs && \
30
- node openclaw.mjs gateway \
31
- --allow-unconfigured \
32
- --bind lan \
33
- --port 7860
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:22-bookworm
2
 
3
+ ARG OPENCLAW_REPO=https://github.com/Josephrp/openclaw.git
4
+ ARG OPENCLAW_REF=hf-spaces
5
 
6
+ # 系统依赖 + Bun
7
+ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git ca-certificates && \
8
+ apt-get clean && rm -rf /var/lib/apt/lists/* && \
9
+ curl -fsSL https://bun.sh/install | bash
10
  ENV PATH="/root/.bun/bin:${PATH}"
 
 
 
 
 
 
 
11
  RUN corepack enable
12
 
13
+ WORKDIR /app
 
 
 
14
 
15
+ # Clone OpenClaw + build backend + UI
16
+ RUN git clone --depth 1 --branch "${OPENCLAW_REF}" "${OPENCLAW_REPO}" . && \
17
+ pnpm install --frozen-lockfile && \
18
+ pnpm build && \
19
+ pnpm ui:build
20
 
21
+ ENV NODE_ENV=production
22
+ ENV OPENCLAW_PREFER_PNPM=1
23
  EXPOSE 7860
24
 
25
+ # Copy our production setup
26
+ COPY setup-hf-config.mjs /app/setup-hf-config.mjs
27
+
28
+ # Entrypoint: setup config + start gateway
29
+ RUN printf '%s\n' \
30
+ '#!/bin/sh' \
31
+ 'set -e' \
32
+ 'if mkdir -p /data/.openclaw 2>/dev/null; then' \
33
+ ' export OPENCLAW_HOME=/data' \
34
+ 'else' \
35
+ ' export OPENCLAW_HOME=/home/user' \
36
+ ' mkdir -p /home/user/.openclaw' \
37
+ 'fi' \
38
+ 'node /app/setup-hf-config.mjs' \
39
+ 'exec node /app/openclaw.mjs gateway --allow-unconfigured --bind lan --port 7860 "$@"' \
40
+ > /app/entrypoint.sh && chmod +x /app/entrypoint.sh
41
+
42
+ RUN chown -R node:node /app && mkdir -p /home/user && chown -R node:node /home/user
43
+ USER node
44
+ ENTRYPOINT ["/app/entrypoint.sh"]