zhvzii commited on
Commit
c192023
·
verified ·
1 Parent(s): f77018d

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +33 -18
Dockerfile CHANGED
@@ -1,24 +1,39 @@
1
- # Dockerfile
2
- FROM node:22-slim
3
 
4
- # 安装 pnpm(关键步骤)
5
- RUN npm install -g pnpm corepack && corepack enable
 
6
 
7
- # 安装构建依赖(OpenClaw 需要编译 native 模块)
8
- RUN apt-get update && apt-get install -y \
9
- build-essential \
10
- python3 \
11
- pkg-config \
12
- libvips-dev \
13
- && rm -rf /var/lib/apt/lists/*
14
 
15
- # 克隆 OpenClaw 源码
16
  WORKDIR /app
17
- RUN git clone https://github.com/openclaw/openclaw.git . \
18
- && pnpm install --frozen-lockfile
19
 
20
- # 持久化数据目录(但 Spaces 免费版仍会丢失)
21
- VOLUME ["/root/.openclaw"]
 
 
 
 
 
22
 
23
- # 启动 OpenClaw
24
- CMD ["pnpm", "start"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:22-bookworm
 
2
 
3
+ # Install Bun (required for build scripts)
4
+ RUN curl -fsSL https://bun.sh/install | bash
5
+ ENV PATH="/root/.bun/bin:${PATH}"
6
 
7
+ RUN corepack enable
 
 
 
 
 
 
8
 
 
9
  WORKDIR /app
 
 
10
 
11
+ ARG OPENCLAW_DOCKER_APT_PACKAGES=""
12
+ RUN if [ -n "$OPENCLAW_DOCKER_APT_PACKAGES" ]; then \
13
+ apt-get update && \
14
+ DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends $OPENCLAW_DOCKER_APT_PACKAGES && \
15
+ apt-get clean && \
16
+ rm -rf /var/lib/apt/lists/* /var/cache/apt/archives/*; \
17
+ fi
18
 
19
+ COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./
20
+ COPY ui/package.json ./ui/package.json
21
+ COPY patches ./patches
22
+ COPY scripts ./scripts
23
+
24
+ RUN pnpm install --frozen-lockfile
25
+
26
+ COPY . .
27
+ RUN OPENCLAW_A2UI_SKIP_MISSING=1 pnpm build
28
+ # Force pnpm for UI build (Bun may fail on ARM/Synology architectures)
29
+ ENV OPENCLAW_PREFER_PNPM=1
30
+ RUN pnpm ui:build
31
+
32
+ ENV NODE_ENV=production
33
+
34
+ # Security hardening: Run as non-root user
35
+ # The node:22-bookworm image includes a 'node' user (uid 1000)
36
+ # This reduces the attack surface by preventing container escape via root privileges
37
+ USER node
38
+
39
+ CMD ["node", "dist/index.js"]