syw1516 commited on
Commit
e14769e
·
verified ·
1 Parent(s): 8994f14

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +28 -10
Dockerfile CHANGED
@@ -1,29 +1,22 @@
1
-
2
  FROM docker.io/library/ubuntu:24.04
3
 
4
- # 设置环境变量
5
  ENV DEBIAN_FRONTEND=noninteractive
6
  ENV TZ=Etc/UTC
7
 
8
- # 安装必要依赖
9
  RUN apt-get update && apt-get install -y \
10
  curl \
11
  git \
12
  python3-pip \
13
  && rm -rf /var/lib/apt/lists/*
14
 
15
- # 安装Node.js
16
  RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
17
  && apt-get install -y nodejs
18
 
19
- # 安装OpenClaw和huggingface_hub
20
  RUN npm install -g openclaw@latest
21
  RUN pip3 install --break-system-packages huggingface_hub -q
22
 
23
- # 创建必要的目录
24
  RUN mkdir -p /root/.openclaw /data /var/log/openclaw /scripts
25
 
26
- # 直接在Dockerfile里写入脚本(避免换行符问题)
27
  RUN printf '#!/bin/bash\n\
28
  set -euo pipefail\n\
29
  \n\
@@ -70,8 +63,35 @@ backup_on_start() {\n\
70
  rm -rf "${BACKUP_TEMP}"\n\
71
  }\n\
72
  \n\
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  main() {\n\
74
  log_info "===== OpenClaw 启动 ====="\n\
 
75
  restore_if_exists\n\
76
  backup_on_start\n\
77
  log_info "启动 OpenClaw 网关..."\n\
@@ -81,8 +101,6 @@ main "$@"\n' > /scripts/openclaw-entrypoint.sh
81
 
82
  RUN chmod +x /scripts/openclaw-entrypoint.sh
83
 
84
- # 暴露端口
85
  EXPOSE 7860
86
 
87
- # 入口点
88
- ENTRYPOINT ["/scripts/openclaw-entrypoint.sh"]
 
 
1
  FROM docker.io/library/ubuntu:24.04
2
 
 
3
  ENV DEBIAN_FRONTEND=noninteractive
4
  ENV TZ=Etc/UTC
5
 
 
6
  RUN apt-get update && apt-get install -y \
7
  curl \
8
  git \
9
  python3-pip \
10
  && rm -rf /var/lib/apt/lists/*
11
 
 
12
  RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - \
13
  && apt-get install -y nodejs
14
 
 
15
  RUN npm install -g openclaw@latest
16
  RUN pip3 install --break-system-packages huggingface_hub -q
17
 
 
18
  RUN mkdir -p /root/.openclaw /data /var/log/openclaw /scripts
19
 
 
20
  RUN printf '#!/bin/bash\n\
21
  set -euo pipefail\n\
22
  \n\
 
63
  rm -rf "${BACKUP_TEMP}"\n\
64
  }\n\
65
  \n\
66
+ init_config() {\n\
67
+ local config_file="${OPENCLAW_STATE_DIR}/openclaw.json"\n\
68
+ if [[ ! -f "${config_file}" ]]; then\n\
69
+ log_info "初始化 OpenClaw 配置..."\n\
70
+ cat > "${config_file}" <<'"'"'EOFCONFIG'"'"'\n\
71
+ {\n\
72
+ "gateway": {\n\
73
+ "mode": "local",\n\
74
+ "bind": "lan",\n\
75
+ "auth": {\n\
76
+ "mode": "token"\n\
77
+ }\n\
78
+ },\n\
79
+ "agents": {\n\
80
+ "defaults": {\n\
81
+ "model": {\n\
82
+ "primary": "local"\n\
83
+ }\n\
84
+ }\n\
85
+ }\n\
86
+ }\n\
87
+ EOFCONFIG\n\
88
+ log_info "配置初始化完成"\n\
89
+ fi\n\
90
+ }\n\
91
+ \n\
92
  main() {\n\
93
  log_info "===== OpenClaw 启动 ====="\n\
94
+ init_config\n\
95
  restore_if_exists\n\
96
  backup_on_start\n\
97
  log_info "启动 OpenClaw 网关..."\n\
 
101
 
102
  RUN chmod +x /scripts/openclaw-entrypoint.sh
103
 
 
104
  EXPOSE 7860
105
 
106
+ ENTRYPOINT ["/scripts/openclaw-entrypoint.sh"]