echo8900 commited on
Commit
5afa9ee
·
verified ·
1 Parent(s): 08cb7ae

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +23 -13
Dockerfile CHANGED
@@ -1,10 +1,9 @@
1
- FROM node:22-bookworm
2
 
3
- # 安装系统依赖
4
  RUN apt-get update && \
5
- DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
6
- git ca-certificates nginx \
7
- && apt-get clean && rm -rf /var/lib/apt/lists/* && \
8
  curl -fsSL https://bun.sh/install | bash
9
 
10
  ENV PATH="/root/.bun/bin:${PATH}"
@@ -12,7 +11,6 @@ RUN corepack enable
12
 
13
  WORKDIR /app
14
 
15
- # 克隆并构建 OpenClaw(这是必须的步骤)
16
  ARG OPENCLAW_REPO=https://github.com/Josephrp/openclaw.git
17
  ARG OPENCLAW_REF=hf-spaces
18
 
@@ -21,20 +19,32 @@ RUN git clone --depth 1 --branch "${OPENCLAW_REF}" "${OPENCLAW_REPO}" . && \
21
  pnpm build && \
22
  pnpm ui:build
23
 
24
- ENV OPENCLAW_PREFER_PNPM=1
25
- ENV NODE_ENV=production
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
- # 复制你的配置文件
28
  COPY nginx.conf /etc/nginx/conf.d/openclaw.conf
29
  COPY setup-hf-config.mjs /app/setup-hf-config.mjs
30
  COPY start.sh /start.sh
31
-
32
  RUN chmod +x /start.sh
33
 
 
 
 
34
  # 权限设置
35
- RUN chown -R node:node /app && \
36
- mkdir -p /home/user && \
37
- chown -R node:node /home/user
38
 
39
  USER node
40
 
 
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
 
12
  WORKDIR /app
13
 
 
14
  ARG OPENCLAW_REPO=https://github.com/Josephrp/openclaw.git
15
  ARG OPENCLAW_REF=hf-spaces
16
 
 
19
  pnpm build && \
20
  pnpm ui:build
21
 
22
+ # 最终运行阶段
23
+ FROM node:22-bookworm
24
+
25
+ USER root
26
+
27
+ RUN apt-get update && \
28
+ apt-get install -y --no-install-recommends nginx && \
29
+ apt-get clean && rm -rf /var/lib/apt/lists/*
30
+
31
+ # 创建 nginx 所需目录并设置权限
32
+ RUN mkdir -p /var/lib/nginx/body /var/lib/nginx/tmp /var/log/nginx && \
33
+ chown -R node:node /var/lib/nginx /var/log/nginx
34
+
35
+ RUN rm -f /etc/nginx/sites-enabled/default \
36
+ && rm -f /etc/nginx/conf.d/default.conf
37
 
 
38
  COPY nginx.conf /etc/nginx/conf.d/openclaw.conf
39
  COPY setup-hf-config.mjs /app/setup-hf-config.mjs
40
  COPY start.sh /start.sh
 
41
  RUN chmod +x /start.sh
42
 
43
+ # 使用环境变量传递 Token
44
+ ENV OPENCLAW_TOKEN=Li8900
45
+
46
  # 权限设置
47
+ RUN chown -R node:node /app /home/user
 
 
48
 
49
  USER node
50