8900 commited on
Commit
58a61b8
·
verified ·
1 Parent(s): c5bc2fb

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -21
Dockerfile CHANGED
@@ -1,9 +1,12 @@
1
- FROM node:22-bookworm AS builder
 
 
2
 
3
- # 预构建阶段
4
  RUN apt-get update && \
5
- apt-get install -y --no-install-recommends git ca-certificates && \
6
- apt-get clean && rm -rf /var/lib/apt/lists/* && \
 
7
  curl -fsSL https://bun.sh/install | bash
8
 
9
  ENV PATH="/root/.bun/bin:${PATH}"
@@ -11,6 +14,7 @@ RUN corepack enable
11
 
12
  WORKDIR /app
13
 
 
14
  ARG OPENCLAW_REPO=https://github.com/Josephrp/openclaw.git
15
  ARG OPENCLAW_REF=hf-spaces
16
 
@@ -19,33 +23,21 @@ RUN git clone --depth 1 --branch "${OPENCLAW_REF}" "${OPENCLAW_REPO}" . && \
19
  pnpm build && \
20
  pnpm ui:build
21
 
22
- # 最终运行阶段(权限优化版)
23
- FROM node:22-bookworm
24
 
25
- USER root
26
-
27
- # 安装 nginx 并创建所有必要目录 + 统一权限设置(合并到一个 RUN,减少层数)
28
- RUN apt-get update && \
29
- apt-get install -y --no-install-recommends nginx && \
30
- apt-get clean && rm -rf /var/lib/apt/lists/* && \
31
- mkdir -p /var/lib/nginx/body /var/lib/nginx/tmp /var/log/nginx /home/user /app && \
32
- chown -R node:node /var/lib/nginx /var/log/nginx /home/user /app
33
-
34
- # 清理默认 nginx 配置
35
- RUN rm -f /etc/nginx/sites-enabled/default \
36
- && rm -f /etc/nginx/conf.d/default.conf
37
 
38
  # 复制配置文件
39
  COPY nginx.conf /etc/nginx/conf.d/openclaw.conf
40
  COPY setup-hf-config.mjs /app/setup-hf-config.mjs
41
  COPY start.sh /start.sh
42
-
43
  RUN chmod +x /start.sh
44
 
45
- # 环境变量
46
  ENV OPENCLAW_TOKEN=Li8900
47
 
48
- # 切换到普通用户
49
  USER node
50
 
51
  EXPOSE 7860
 
1
+ FROM node:22-bookworm
2
+
3
+ USER root
4
 
5
+ # 安装必要工具
6
  RUN apt-get update && \
7
+ apt-get install -y --no-install-recommends \
8
+ git ca-certificates nginx \
9
+ && apt-get clean && rm -rf /var/lib/apt/lists/* && \
10
  curl -fsSL https://bun.sh/install | bash
11
 
12
  ENV PATH="/root/.bun/bin:${PATH}"
 
14
 
15
  WORKDIR /app
16
 
17
+ # 从源码构建 OpenClaw(必须步骤)
18
  ARG OPENCLAW_REPO=https://github.com/Josephrp/openclaw.git
19
  ARG OPENCLAW_REF=hf-spaces
20
 
 
23
  pnpm build && \
24
  pnpm ui:build
25
 
26
+ ENV OPENCLAW_PREFER_PNPM=1
27
+ ENV NODE_ENV=production
28
 
29
+ # 创建必要目录并修复权限
30
+ RUN mkdir -p /var/lib/nginx/body /var/lib/nginx/tmp /var/log/nginx /run/nginx /home/user && \
31
+ chown -R node:node /var/lib/nginx /var/log/nginx /run/nginx /home/user /app
 
 
 
 
 
 
 
 
 
32
 
33
  # 复制配置文件
34
  COPY nginx.conf /etc/nginx/conf.d/openclaw.conf
35
  COPY setup-hf-config.mjs /app/setup-hf-config.mjs
36
  COPY start.sh /start.sh
 
37
  RUN chmod +x /start.sh
38
 
 
39
  ENV OPENCLAW_TOKEN=Li8900
40
 
 
41
  USER node
42
 
43
  EXPOSE 7860