Update Dockerfile
Browse files- Dockerfile +33 -44
Dockerfile
CHANGED
|
@@ -9,19 +9,12 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
| 9 |
python3 \
|
| 10 |
python3-pip \
|
| 11 |
ca-certificates \
|
|
|
|
|
|
|
| 12 |
&& rm -rf /var/lib/apt/lists/*
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
curl \
|
| 17 |
-
jq \
|
| 18 |
-
&& rm -rf /var/lib/apt/lists/*
|
| 19 |
-
|
| 20 |
-
# ========= HF CLI =========
|
| 21 |
-
RUN pip3 install --no-cache-dir huggingface_hub --break-system-packages
|
| 22 |
-
|
| 23 |
-
# 安装 Python requests
|
| 24 |
-
RUN pip3 install --no-cache-dir requests slack-sdk --break-system-packages
|
| 25 |
|
| 26 |
# ========= Git HTTPS fallback =========
|
| 27 |
RUN git config --global url."https://github.com/".insteadOf ssh://git@github.com/
|
|
@@ -29,12 +22,10 @@ RUN git config --global url."https://github.com/".insteadOf ssh://git@github.com
|
|
| 29 |
# ========= OpenClaw =========
|
| 30 |
RUN npm install -g openclaw@latest --unsafe-perm
|
| 31 |
|
| 32 |
-
#
|
| 33 |
-
# RUN chmod +x /usr/local/bin/auto-approve.sh
|
| 34 |
COPY auto-approve.py /usr/local/bin/auto-approve.py
|
| 35 |
RUN chmod +x /usr/local/bin/auto-approve.py
|
| 36 |
|
| 37 |
-
|
| 38 |
# ========= ENV =========
|
| 39 |
ENV PORT=7860 \
|
| 40 |
OPENCLAW_GATEWAY_MODE=local \
|
|
@@ -112,7 +103,7 @@ if __name__ == "__main__":
|
|
| 112 |
restore()
|
| 113 |
PYEOF
|
| 114 |
|
| 115 |
-
# ========= start
|
| 116 |
RUN cat <<'SHEOF' > /usr/local/bin/start-openclaw
|
| 117 |
#!/bin/bash
|
| 118 |
set -e
|
|
@@ -133,9 +124,7 @@ else
|
|
| 133 |
CLEAN_BASE="https://api.siliconflow.cn/v1"
|
| 134 |
fi
|
| 135 |
|
| 136 |
-
#
|
| 137 |
-
# Slack
|
| 138 |
-
# ---------------------------
|
| 139 |
if [ -n "$SLACK_BOT_TOKEN" ]; then
|
| 140 |
cat > /root/.openclaw/credentials/slack.json <<EOF
|
| 141 |
{
|
|
@@ -145,7 +134,7 @@ cat > /root/.openclaw/credentials/slack.json <<EOF
|
|
| 145 |
EOF
|
| 146 |
fi
|
| 147 |
|
| 148 |
-
#
|
| 149 |
cat > /root/.openclaw/openclaw.json <<EOF
|
| 150 |
{
|
| 151 |
"models":{
|
|
@@ -199,26 +188,14 @@ while true; do
|
|
| 199 |
done
|
| 200 |
) &
|
| 201 |
|
| 202 |
-
# Run doctor
|
| 203 |
openclaw doctor --fix || true
|
| 204 |
|
| 205 |
-
#
|
| 206 |
-
# Slack 自动 approve ,需要slack先发送消息,获得paring code
|
| 207 |
-
# ---------------------------
|
| 208 |
-
#openclaw pairing approve slack H3CBFPEN
|
| 209 |
-
|
| 210 |
-
# Start gateway foreground
|
| 211 |
-
#exec openclaw gateway run --port $PORT
|
| 212 |
-
|
| 213 |
-
# 设置 Gateway token 环境变量(自动完成 pairing)
|
| 214 |
-
export OPENCLAW_GATEWAY_TOKEN="$OPENCLAW_GATEWAY_PASSWORD"
|
| 215 |
-
|
| 216 |
echo "--- Starting OpenClaw Gateway ---"
|
| 217 |
openclaw gateway run --port $PORT &
|
| 218 |
|
| 219 |
-
#
|
| 220 |
-
# 等待 gateway ready
|
| 221 |
-
# ---------------------------
|
| 222 |
echo "--- Waiting for Gateway to be ready ---"
|
| 223 |
for i in {1..30}; do
|
| 224 |
if curl -s -H "Authorization: Bearer $OPENCLAW_GATEWAY_PASSWORD" \
|
|
@@ -229,22 +206,34 @@ for i in {1..30}; do
|
|
| 229 |
sleep 1
|
| 230 |
done
|
| 231 |
|
| 232 |
-
#
|
| 233 |
-
# 自动 approve Slack pairing code
|
| 234 |
-
# ---------------------------
|
| 235 |
echo "--- Starting auto-approve.py ---"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
|
| 237 |
-
|
| 238 |
-
|
|
|
|
| 239 |
|
| 240 |
-
#
|
| 241 |
-
# 保持前台运行,防止容器退出
|
| 242 |
-
# ---------------------------
|
| 243 |
wait
|
| 244 |
SHEOF
|
| 245 |
|
| 246 |
RUN chmod +x /usr/local/bin/start-openclaw
|
| 247 |
|
|
|
|
| 248 |
EXPOSE 7860
|
| 249 |
-
CMD ["/usr/local/bin/start-openclaw"]
|
| 250 |
-
|
|
|
|
| 9 |
python3 \
|
| 10 |
python3-pip \
|
| 11 |
ca-certificates \
|
| 12 |
+
curl \
|
| 13 |
+
jq \
|
| 14 |
&& rm -rf /var/lib/apt/lists/*
|
| 15 |
|
| 16 |
+
# ========= HF CLI & Python deps =========
|
| 17 |
+
RUN pip3 install --no-cache-dir huggingface_hub requests slack-sdk --break-system-packages
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# ========= Git HTTPS fallback =========
|
| 20 |
RUN git config --global url."https://github.com/".insteadOf ssh://git@github.com/
|
|
|
|
| 22 |
# ========= OpenClaw =========
|
| 23 |
RUN npm install -g openclaw@latest --unsafe-perm
|
| 24 |
|
| 25 |
+
# ========= Copy scripts =========
|
|
|
|
| 26 |
COPY auto-approve.py /usr/local/bin/auto-approve.py
|
| 27 |
RUN chmod +x /usr/local/bin/auto-approve.py
|
| 28 |
|
|
|
|
| 29 |
# ========= ENV =========
|
| 30 |
ENV PORT=7860 \
|
| 31 |
OPENCLAW_GATEWAY_MODE=local \
|
|
|
|
| 103 |
restore()
|
| 104 |
PYEOF
|
| 105 |
|
| 106 |
+
# ========= start-openclaw =========
|
| 107 |
RUN cat <<'SHEOF' > /usr/local/bin/start-openclaw
|
| 108 |
#!/bin/bash
|
| 109 |
set -e
|
|
|
|
| 124 |
CLEAN_BASE="https://api.siliconflow.cn/v1"
|
| 125 |
fi
|
| 126 |
|
| 127 |
+
# Slack credentials
|
|
|
|
|
|
|
| 128 |
if [ -n "$SLACK_BOT_TOKEN" ]; then
|
| 129 |
cat > /root/.openclaw/credentials/slack.json <<EOF
|
| 130 |
{
|
|
|
|
| 134 |
EOF
|
| 135 |
fi
|
| 136 |
|
| 137 |
+
# OpenClaw config
|
| 138 |
cat > /root/.openclaw/openclaw.json <<EOF
|
| 139 |
{
|
| 140 |
"models":{
|
|
|
|
| 188 |
done
|
| 189 |
) &
|
| 190 |
|
| 191 |
+
# Run doctor
|
| 192 |
openclaw doctor --fix || true
|
| 193 |
|
| 194 |
+
# Start Gateway
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 195 |
echo "--- Starting OpenClaw Gateway ---"
|
| 196 |
openclaw gateway run --port $PORT &
|
| 197 |
|
| 198 |
+
# Wait for Gateway ready
|
|
|
|
|
|
|
| 199 |
echo "--- Waiting for Gateway to be ready ---"
|
| 200 |
for i in {1..30}; do
|
| 201 |
if curl -s -H "Authorization: Bearer $OPENCLAW_GATEWAY_PASSWORD" \
|
|
|
|
| 206 |
sleep 1
|
| 207 |
done
|
| 208 |
|
| 209 |
+
# Auto approve Slack pairing
|
|
|
|
|
|
|
| 210 |
echo "--- Starting auto-approve.py ---"
|
| 211 |
+
python3 -u /usr/local/bin/auto-approve.py &
|
| 212 |
+
|
| 213 |
+
# Wait for frontend pairing
|
| 214 |
+
echo "--- Waiting for frontend pairing ---"
|
| 215 |
+
paired=0
|
| 216 |
+
for i in {1..60}; do
|
| 217 |
+
status=$(curl -s -H "Authorization: Bearer $OPENCLAW_GATEWAY_PASSWORD" \
|
| 218 |
+
http://127.0.0.1:$PORT/api/status || echo "")
|
| 219 |
+
if echo "$status" | grep -q '"connectedClients":[1-9]'; then
|
| 220 |
+
echo "✅ Gateway paired with frontend"
|
| 221 |
+
paired=1
|
| 222 |
+
break
|
| 223 |
+
fi
|
| 224 |
+
sleep 1
|
| 225 |
+
done
|
| 226 |
|
| 227 |
+
if [ "$paired" -ne 1 ]; then
|
| 228 |
+
echo "⚠️ Warning: no frontend connected after 60s"
|
| 229 |
+
fi
|
| 230 |
|
| 231 |
+
# Keep foreground
|
|
|
|
|
|
|
| 232 |
wait
|
| 233 |
SHEOF
|
| 234 |
|
| 235 |
RUN chmod +x /usr/local/bin/start-openclaw
|
| 236 |
|
| 237 |
+
# ========= Ports & CMD =========
|
| 238 |
EXPOSE 7860
|
| 239 |
+
CMD ["/usr/local/bin/start-openclaw"]
|
|
|