darkfire514 commited on
Commit
cd0659b
·
verified ·
1 Parent(s): 9790f1b

Upload 6 files

Browse files
Files changed (3) hide show
  1. Dockerfile +2 -3
  2. nginx.conf +5 -5
  3. start.sh +5 -55
Dockerfile CHANGED
@@ -40,10 +40,9 @@ RUN wget https://github.com/oauth2-proxy/oauth2-proxy/releases/download/v7.6.0/o
40
  && chmod +x /usr/bin/oauth2-proxy \
41
  && rm -rf oauth2-proxy-v7.6.0.linux-amd64*
42
 
43
- # Install Node.js and OpenClaw
44
  RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
45
- apt-get install -y nodejs && \
46
- npm install -g openclaw@latest
47
 
48
  # Create a non-root user 'user' (UID 1000)
49
  RUN useradd -m -u 1000 user && \
 
40
  && chmod +x /usr/bin/oauth2-proxy \
41
  && rm -rf oauth2-proxy-v7.6.0.linux-amd64*
42
 
43
+ # Install Node.js (for manual OpenClaw installation later)
44
  RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
45
+ apt-get install -y nodejs
 
46
 
47
  # Create a non-root user 'user' (UID 1000)
48
  RUN useradd -m -u 1000 user && \
nginx.conf CHANGED
@@ -53,12 +53,12 @@ http {
53
  # Protected Resources
54
  # =========================================================
55
 
56
- # 1. OpenClaw Dashboard - Root Path /
57
  location / {
58
  auth_request /oauth2/auth;
59
  error_page 401 = /oauth2/sign_in;
60
 
61
- proxy_pass http://127.0.0.1:18789;
62
  proxy_http_version 1.1;
63
  proxy_set_header Upgrade $http_upgrade;
64
  proxy_set_header Connection "upgrade";
@@ -70,12 +70,12 @@ http {
70
  proxy_set_header X-Forwarded-Email $upstream_http_x_forwarded_email;
71
  }
72
 
73
- # 2. Terminal (ttyd) - /terminal/ Path
74
- location /terminal/ {
75
  auth_request /oauth2/auth;
76
  error_page 401 = /oauth2/sign_in;
77
 
78
- proxy_pass http://127.0.0.1:7681;
79
  proxy_http_version 1.1;
80
  proxy_set_header Upgrade $http_upgrade;
81
  proxy_set_header Connection "upgrade";
 
53
  # Protected Resources
54
  # =========================================================
55
 
56
+ # 1. Terminal (ttyd) - Root Path /
57
  location / {
58
  auth_request /oauth2/auth;
59
  error_page 401 = /oauth2/sign_in;
60
 
61
+ proxy_pass http://127.0.0.1:7681;
62
  proxy_http_version 1.1;
63
  proxy_set_header Upgrade $http_upgrade;
64
  proxy_set_header Connection "upgrade";
 
70
  proxy_set_header X-Forwarded-Email $upstream_http_x_forwarded_email;
71
  }
72
 
73
+ # 2. OpenClaw Dashboard - /ui/ Path (for manual start later)
74
+ location /ui/ {
75
  auth_request /oauth2/auth;
76
  error_page 401 = /oauth2/sign_in;
77
 
78
+ proxy_pass http://127.0.0.1:18789/;
79
  proxy_http_version 1.1;
80
  proxy_set_header Upgrade $http_upgrade;
81
  proxy_set_header Connection "upgrade";
start.sh CHANGED
@@ -54,63 +54,12 @@ fi
54
  # =========================================================
55
 
56
  # 1. 启动 ttyd (本地监听 7681)
 
57
  echo "Starting ttyd on 127.0.0.1:7681..."
58
- ttyd -p 7681 -i 127.0.0.1 -b /terminal -W bash &
59
  TTYD_PID=$!
60
 
61
- # 2. 启动 OpenClaw Gateway (本地监听 18789)
62
- echo "Starting OpenClaw Gateway..."
63
-
64
- # 设置 OpenClaw 环境变量
65
- export PORT=18789
66
- export OPENCLAW_PORT=18789
67
- export HOST=127.0.0.1
68
- export OPENCLAW_NON_INTERACTIVE=true
69
-
70
- # 打印当前安装的 OpenClaw 版本
71
- openclaw --version || echo "Cannot get openclaw version"
72
-
73
- # 启动 OpenClaw 并直接输出到控制台 (使用 tail 实时监控)
74
- touch /tmp/openclaw.log
75
- if command -v openclaw &> /dev/null; then
76
- echo "Executing: openclaw gateway run"
77
- openclaw gateway run > /tmp/openclaw.log 2>&1 &
78
- OPENCLAW_PID=$!
79
- else
80
- echo "Executing: npx openclaw gateway run"
81
- npx openclaw gateway run > /tmp/openclaw.log 2>&1 &
82
- OPENCLAW_PID=$!
83
- fi
84
-
85
- # 启动一个后台任务实时打印 OpenClaw 日志到控制台,方便在 HF Logs 查看
86
- tail -f /tmp/openclaw.log &
87
- LOG_TAIL_PID=$!
88
-
89
- # 等待 OpenClaw 启动 (最多 30 秒)
90
- for i in {1..30}; do
91
- if nc -z 127.0.0.1 18789; then
92
- echo "SUCCESS: OpenClaw Gateway is up and running on port 18789!"
93
- break
94
- fi
95
-
96
- # 打印当前监听的端口,看看它到底躲在哪个端口了
97
- if [ $((i % 5)) -eq 0 ]; then
98
- echo "Current listening ports:"
99
- netstat -tulpn | grep LISTEN
100
- fi
101
-
102
- echo "Waiting for OpenClaw (attempt $i/30)..."
103
-
104
- if ! kill -0 $OPENCLAW_PID 2>/dev/null; then
105
- echo "CRITICAL: OpenClaw process died! Final logs:"
106
- cat /tmp/openclaw.log
107
- break
108
- fi
109
-
110
- sleep 1
111
- done
112
-
113
- # 3. 启动 oauth2-proxy (本地监听 4180)
114
  # 回退到稳定模式:根据环境变量智能选择单个 Provider
115
  echo "Starting oauth2-proxy on 127.0.0.1:4180..."
116
 
@@ -133,6 +82,7 @@ else
133
  fi
134
 
135
  # 构建 oauth2-proxy 命令 (标准命令行模式)
 
136
  CMD="oauth2-proxy \
137
  --config=oauth2-proxy.cfg \
138
  --provider=$OAUTH2_PROXY_PROVIDER \
@@ -140,7 +90,7 @@ CMD="oauth2-proxy \
140
  --client-secret=$OAUTH2_PROXY_CLIENT_SECRET \
141
  --cookie-secret=$OAUTH2_PROXY_COOKIE_SECRET \
142
  --email-domain=* \
143
- --upstream=http://127.0.0.1:18789 \
144
  --http-address=127.0.0.1:4180 \
145
  --authenticated-emails-file=$AUTH_FILE"
146
 
 
54
  # =========================================================
55
 
56
  # 1. 启动 ttyd (本地监听 7681)
57
+ # -b /: 设置 Web 终端为根路径,登录即是终端
58
  echo "Starting ttyd on 127.0.0.1:7681..."
59
+ ttyd -p 7681 -i 127.0.0.1 -W bash &
60
  TTYD_PID=$!
61
 
62
+ # 2. 启动 oauth2-proxy (本地监听 4180)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  # 回退到稳定模式:根据环境变量智能选择单个 Provider
64
  echo "Starting oauth2-proxy on 127.0.0.1:4180..."
65
 
 
82
  fi
83
 
84
  # 构建 oauth2-proxy 命令 (标准命令行模式)
85
+ # 上游指向 ttyd (127.0.0.1:7681)
86
  CMD="oauth2-proxy \
87
  --config=oauth2-proxy.cfg \
88
  --provider=$OAUTH2_PROXY_PROVIDER \
 
90
  --client-secret=$OAUTH2_PROXY_CLIENT_SECRET \
91
  --cookie-secret=$OAUTH2_PROXY_COOKIE_SECRET \
92
  --email-domain=* \
93
+ --upstream=http://127.0.0.1:7681 \
94
  --http-address=127.0.0.1:4180 \
95
  --authenticated-emails-file=$AUTH_FILE"
96