underrate commited on
Commit
afd397f
ยท
verified ยท
1 Parent(s): dfac23c

Now just OpenClaw gateway with the built-in dashboard.

Browse files
Files changed (3) hide show
  1. Dockerfile +8 -14
  2. README.md +15 -94
  3. start.sh +20 -34
Dockerfile CHANGED
@@ -1,10 +1,9 @@
1
  FROM node:22-slim
2
 
3
- # Install system dependencies including git and netcat
4
  RUN apt-get update && apt-get install -y \
5
  curl \
6
  git \
7
- netcat-openbsd \
8
  python3 \
9
  build-essential \
10
  && rm -rf /var/lib/apt/lists/*
@@ -12,18 +11,8 @@ RUN apt-get update && apt-get install -y \
12
  # Install OpenClaw globally
13
  RUN npm install -g openclaw
14
 
15
- # Create app directory
16
- WORKDIR /app
17
-
18
- # Copy package.json and install dependencies
19
- COPY package.json /app/package.json
20
- RUN npm install
21
-
22
- # Copy application files
23
- COPY public /app/public
24
- COPY server.js /app/server.js
25
- COPY start.sh /app/start.sh
26
- RUN chmod +x /app/start.sh
27
 
28
  # Expose port
29
  EXPOSE 7860
@@ -33,5 +22,10 @@ ENV BASE_URL=""
33
  ENV API_KEY=""
34
  ENV MODEL_ID="Multiple-models"
35
  ENV PROVIDER_NAME="custom"
 
 
 
 
 
36
 
37
  CMD ["/app/start.sh"]
 
1
  FROM node:22-slim
2
 
3
+ # Install system dependencies
4
  RUN apt-get update && apt-get install -y \
5
  curl \
6
  git \
 
7
  python3 \
8
  build-essential \
9
  && rm -rf /var/lib/apt/lists/*
 
11
  # Install OpenClaw globally
12
  RUN npm install -g openclaw
13
 
14
+ # Create workspace
15
+ RUN mkdir -p /root/.openclaw/workspace
 
 
 
 
 
 
 
 
 
 
16
 
17
  # Expose port
18
  EXPOSE 7860
 
22
  ENV API_KEY=""
23
  ENV MODEL_ID="Multiple-models"
24
  ENV PROVIDER_NAME="custom"
25
+ ENV GATEWAY_TOKEN="hf-space-token"
26
+
27
+ # Copy start script
28
+ COPY start.sh /app/start.sh
29
+ RUN chmod +x /app/start.sh
30
 
31
  CMD ["/app/start.sh"]
README.md CHANGED
@@ -1,5 +1,5 @@
1
  ---
2
- title: OpenClaw Web Chat
3
  emoji: ๐Ÿฆž
4
  colorFrom: blue
5
  colorTo: purple
@@ -7,106 +7,27 @@ sdk: docker
7
  pinned: false
8
  ---
9
 
10
- # OpenClaw Web Chat
11
 
12
- Deploy your AI assistant to Hugging Face Spaces with a web-based chat interface.
13
 
14
- ## Why Web UI?
15
 
16
- Hugging Face Spaces free tier blocks outbound HTTPS, which prevents Telegram/Discord integrations. This setup uses a web UI that only requires inbound HTTP (which HF allows).
 
 
17
 
18
- ## Setup Instructions
19
 
20
- ### 1. Create Hugging Face Space
 
21
 
22
- 1. Go to [huggingface.co/spaces](https://huggingface.co/spaces)
23
- 2. Click "Create new Space"
24
- 3. Select:
25
- - **Space name**: Your choice (e.g., `my-openclaw-chat`)
26
- - **License**: Apache-2.0
27
- - **Space SDK**: Docker
28
- - **Space hardware**: CPU (free tier)
29
 
30
- ### 2. Upload Files
31
-
32
- Upload these files to your Space:
33
- - `Dockerfile`
34
- - `start.sh`
35
- - `web-server.js`
36
- - `public/index.html`
37
- - `README.md` (this file)
38
-
39
- ### 3. Set Secrets
40
-
41
- In your Space settings, add these secrets:
42
-
43
- | Secret Name | Value | Required |
44
- |-------------|-------|----------|
45
- | `BASE_URL` | Your API URL (e.g., `https://your-9router.hf.space/v1`) | **Yes** |
46
- | `API_KEY` | Your API key | **Yes** |
47
- | `MODEL_ID` | Model name (default: `Multiple-models`) | No |
48
- | `PROVIDER_NAME` | Provider name (default: `custom`) | No |
49
-
50
- **Example for 9router on Hugging Face Spaces:**
51
- ```
52
- BASE_URL=https://your-9router-space.hf.space/v1
53
- API_KEY=your-9router-api-key
54
- MODEL_ID=Multiple-models
55
- PROVIDER_NAME=9router
56
- ```
57
-
58
- ### 4. Access Your Chat
59
-
60
- 1. Wait for the Space to build and start (check logs)
61
- 2. Open your Space URL in a browser
62
- 3. Start chatting with your AI assistant!
63
-
64
- ### 5. Keep It Alive (Optional)
65
-
66
- Sign up at [UptimeRobot](https://uptimerobot.com) and monitor your Space URL to prevent sleeping.
67
-
68
- ## Architecture
69
-
70
- ```
71
- Browser โ†’ HF Space (port 7860) โ†’ Web Server
72
- โ†“
73
- WebSocket Proxy
74
- โ†“
75
- OpenClaw Gateway (port 18789)
76
- โ†“
77
- AI Model API
78
- ```
79
-
80
- ## Features
81
-
82
- - โœ… Clean web chat interface
83
- - โœ… Works on HF Spaces free tier
84
- - โœ… Real-time responses
85
- - โœ… Mobile-friendly design
86
-
87
- ## Troubleshooting
88
-
89
- **"Connection error" in browser?**
90
- - Check Space logs for errors
91
- - Verify `BASE_URL` and `API_KEY` are set correctly
92
- - Make sure your API server is accessible from HF Spaces
93
-
94
- **Blank page?**
95
- - Check browser console for JavaScript errors
96
- - Verify all files were uploaded correctly
97
-
98
- **No response from AI?**
99
- - Check if API is reachable from HF Spaces
100
- - Verify API key is correct
101
- - Check Space logs for API errors
102
 
103
  ## Files
104
 
105
- - `Dockerfile` - Container setup with Node.js + OpenClaw
106
- - `start.sh` - Startup script (runs gateway + web server)
107
- - `web-server.js` - Simple HTTP + WebSocket proxy server
108
- - `public/index.html` - Web chat UI
109
-
110
- ## Credits
111
-
112
- Powered by [OpenClaw](https://github.com/openclaw/openclaw)
 
1
  ---
2
+ title: OpenClaw Dashboard
3
  emoji: ๐Ÿฆž
4
  colorFrom: blue
5
  colorTo: purple
 
7
  pinned: false
8
  ---
9
 
10
+ # OpenClaw Dashboard
11
 
12
+ Access your AI assistant through the OpenClaw dashboard.
13
 
14
+ ## Setup
15
 
16
+ 1. Set these secrets in your Space:
17
+ - `BASE_URL` - Your API URL (e.g., `https://your-9router.hf.space/v1`)
18
+ - `API_KEY` - Your API key
19
 
20
+ 2. Open your Space URL
21
 
22
+ 3. When prompted, enter the gateway token: `hf-space-token`
23
+ (Or set your own via `GATEWAY_TOKEN` secret)
24
 
25
+ ## Usage
 
 
 
 
 
 
26
 
27
+ The dashboard provides a full chat interface with your AI assistant (Zero).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
  ## Files
30
 
31
+ - `Dockerfile` - Container setup
32
+ - `start.sh` - Startup script
33
+ - `README.md` - This file
 
 
 
 
 
start.sh CHANGED
@@ -17,7 +17,10 @@ BASE_URL=${BASE_URL:-"http://127.0.0.1:20128/v1"}
17
  MODEL_ID=${MODEL_ID:-"Multiple-models"}
18
  PROVIDER_NAME=${PROVIDER_NAME:-"custom"}
19
 
20
- # Create OpenClaw config - bind to loopback only (no pairing needed for local)
 
 
 
21
  cat > /root/.openclaw/openclaw.json << EOF
22
  {
23
  "meta": {
@@ -54,10 +57,14 @@ cat > /root/.openclaw/openclaw.json << EOF
54
  },
55
  "session": { "dmScope": "per-channel-peer" },
56
  "gateway": {
57
- "port": 18789,
58
  "mode": "local",
59
- "bind": "loopback",
60
- "auth": { "mode": "none" },
 
 
 
 
61
  "tailscale": { "mode": "off" }
62
  },
63
  "skills": { "install": { "nodeManager": "npm" } },
@@ -65,36 +72,15 @@ cat > /root/.openclaw/openclaw.json << EOF
65
  }
66
  EOF
67
 
68
- echo "โœ… Config created (loopback mode - no pairing)"
69
  echo "๐Ÿ“ก API: ${BASE_URL}"
70
  echo "๐Ÿค– Model: ${MODEL_ID}"
 
 
 
 
 
 
71
 
72
- # Start OpenClaw gateway in background
73
- echo "๐Ÿš€ Starting OpenClaw Gateway..."
74
- openclaw gateway > /tmp/gateway.log 2>&1 &
75
- GATEWAY_PID=$!
76
-
77
- # Wait for gateway to be ready
78
- echo "โณ Waiting for gateway to start..."
79
- for i in {1..60}; do
80
- if nc -z 127.0.0.1 18789 2>/dev/null; then
81
- echo "โœ… Gateway is ready!"
82
- break
83
- fi
84
- if [ $i -eq 60 ]; then
85
- echo "โŒ Gateway failed to start after 60 seconds"
86
- echo "๐Ÿ“‹ Gateway logs:"
87
- cat /tmp/gateway.log
88
- exit 1
89
- fi
90
- sleep 1
91
- done
92
-
93
- # Show gateway status
94
- echo "๐Ÿ“‹ Gateway startup logs:"
95
- head -15 /tmp/gateway.log
96
-
97
- # Start web proxy server
98
- echo "๐ŸŒ Starting Web Proxy..."
99
- cd /app
100
- exec node server.js
 
17
  MODEL_ID=${MODEL_ID:-"Multiple-models"}
18
  PROVIDER_NAME=${PROVIDER_NAME:-"custom"}
19
 
20
+ # Token for gateway auth
21
+ GATEWAY_TOKEN=${GATEWAY_TOKEN:-"hf-space-token"}
22
+
23
+ # Create OpenClaw config
24
  cat > /root/.openclaw/openclaw.json << EOF
25
  {
26
  "meta": {
 
57
  },
58
  "session": { "dmScope": "per-channel-peer" },
59
  "gateway": {
60
+ "port": 7860,
61
  "mode": "local",
62
+ "bind": "lan",
63
+ "auth": {
64
+ "mode": "token",
65
+ "token": "${GATEWAY_TOKEN}"
66
+ },
67
+ "trustedProxies": ["0.0.0.0/0"],
68
  "tailscale": { "mode": "off" }
69
  },
70
  "skills": { "install": { "nodeManager": "npm" } },
 
72
  }
73
  EOF
74
 
75
+ echo "โœ… Config created"
76
  echo "๐Ÿ“ก API: ${BASE_URL}"
77
  echo "๐Ÿค– Model: ${MODEL_ID}"
78
+ echo "๐Ÿ”‘ Gateway Token: ${GATEWAY_TOKEN}"
79
+ echo ""
80
+ echo "๐ŸŒ Starting OpenClaw Gateway..."
81
+ echo "๐Ÿ“ฑ Open your Space URL to access the dashboard"
82
+ echo "๐Ÿ”‘ Use token: ${GATEWAY_TOKEN}"
83
+ echo ""
84
 
85
+ # Start OpenClaw gateway directly
86
+ exec openclaw gateway