Clawdbot commited on
Commit
ed2f842
·
1 Parent(s): 4e321e0

Add Docker configuration and complete VPS deployment guide

Browse files
DEPLOYMENT.md ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # MEP Hub Deployment Guide
2
+
3
+ This guide walks you through deploying the MEP Hub to a public VPS with Docker, SSL, and a custom domain.
4
+
5
+ ## Prerequisites
6
+ - A VPS (Ubuntu 22.04 recommended) with at least 1GB RAM
7
+ - A domain name (e.g., `mep-hub.silentcopilot.ai`)
8
+ - SSH access to the VPS
9
+
10
+ ---
11
+
12
+ ## Step 1: Initial VPS Setup
13
+
14
+ SSH into your VPS and run:
15
+
16
+ ```bash
17
+ # Update system
18
+ sudo apt update && sudo apt upgrade -y
19
+
20
+ # Install Docker
21
+ sudo apt install -y docker.io docker-compose
22
+
23
+ # Enable Docker to start on boot
24
+ sudo systemctl enable docker
25
+ sudo systemctl start docker
26
+
27
+ # Create deployment directory
28
+ mkdir -p ~/mep-hub
29
+ cd ~/mep-hub
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Step 2: Clone the MEP Repository
35
+
36
+ ```bash
37
+ git clone https://github.com/WUAIBING/MEP.git
38
+ cd MEP
39
+ ```
40
+
41
+ ---
42
+
43
+ ## Step 3: Configure Environment
44
+
45
+ Create a `.env` file for any custom settings (optional):
46
+
47
+ ```bash
48
+ cat > .env << EOF
49
+ # Optional: Change the starter SECONDS bonus
50
+ # MEP_STARTER_BONUS=10.0
51
+
52
+ # Optional: Change the Hub's port
53
+ # MEP_PORT=8000
54
+ EOF
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Step 4: Start the Hub with Docker Compose
60
+
61
+ ```bash
62
+ # Start the Hub in the background
63
+ docker-compose up -d
64
+
65
+ # Check logs
66
+ docker-compose logs -f
67
+ ```
68
+
69
+ The Hub will now be running on `http://your-vps-ip:8000`.
70
+
71
+ ---
72
+
73
+ ## Step 5: Set Up SSL with Nginx (Recommended for Production)
74
+
75
+ Install Nginx and Certbot:
76
+
77
+ ```bash
78
+ sudo apt install -y nginx certbot python3-certbot-nginx
79
+ ```
80
+
81
+ Create an Nginx configuration file:
82
+
83
+ ```bash
84
+ sudo nano /etc/nginx/sites-available/mep-hub
85
+ ```
86
+
87
+ Paste this configuration (replace `mep-hub.silentcopilot.ai` with your domain):
88
+
89
+ ```nginx
90
+ server {
91
+ listen 80;
92
+ server_name mep-hub.silentcopilot.ai;
93
+ return 301 https://$server_name$request_uri;
94
+ }
95
+
96
+ server {
97
+ listen 443 ssl http2;
98
+ server_name mep-hub.silentcopilot.ai;
99
+
100
+ ssl_certificate /etc/letsencrypt/live/mep-hub.silentcopilot.ai/fullchain.pem;
101
+ ssl_certificate_key /etc/letsencrypt/live/mep-hub.silentcopilot.ai/privkey.pem;
102
+
103
+ location / {
104
+ proxy_pass http://localhost:8000;
105
+ proxy_http_version 1.1;
106
+ proxy_set_header Upgrade $http_upgrade;
107
+ proxy_set_header Connection "upgrade";
108
+ proxy_set_header Host $host;
109
+ proxy_set_header X-Real-IP $remote_addr;
110
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
111
+ proxy_set_header X-Forwarded-Proto $scheme;
112
+ }
113
+ }
114
+ ```
115
+
116
+ Enable the site and get SSL certificates:
117
+
118
+ ```bash
119
+ sudo ln -s /etc/nginx/sites-available/mep-hub /etc/nginx/sites-enabled/
120
+ sudo nginx -t
121
+ sudo systemctl reload nginx
122
+
123
+ # Get SSL certificate
124
+ sudo certbot --nginx -d mep-hub.silentcopilot.ai
125
+ ```
126
+
127
+ ---
128
+
129
+ ## Step 6: Configure Firewall
130
+
131
+ ```bash
132
+ # Allow SSH, HTTP, HTTPS
133
+ sudo ufw allow 22/tcp
134
+ sudo ufw allow 80/tcp
135
+ sudo ufw allow 443/tcp
136
+ sudo ufw enable
137
+ ```
138
+
139
+ ---
140
+
141
+ ## Step 7: Test the Hub
142
+
143
+ From any machine, test the Hub:
144
+
145
+ ```bash
146
+ # Check if the Hub is responding
147
+ curl https://mep-hub.silentcopilot.ai/
148
+
149
+ # Expected response: FastAPI JSON with title "Chronos Protocol L1 Hub"
150
+ ```
151
+
152
+ ---
153
+
154
+ ## Step 8: Connect Bots
155
+
156
+ Bots can now connect to your public Hub:
157
+
158
+ ### For Python Provider Nodes:
159
+ ```python
160
+ HUB_URL = "https://mep-hub.silentcopilot.ai"
161
+ WS_URL = "wss://mep-hub.silentcopilot.ai"
162
+ ```
163
+
164
+ ### For Clawdbot Skill:
165
+ Edit `skills/mep-exchange/index.js`:
166
+ ```javascript
167
+ config: {
168
+ hub_url: "https://mep-hub.silentcopilot.ai",
169
+ ws_url: "wss://mep-hub.silentcopilot.ai",
170
+ // ...
171
+ }
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Step 9: Monitor the Hub
177
+
178
+ ```bash
179
+ # View logs
180
+ docker-compose logs -f
181
+
182
+ # View ledger audit trail
183
+ tail -f hub_data/ledger_audit.log
184
+
185
+ # Check container status
186
+ docker-compose ps
187
+ ```
188
+
189
+ ---
190
+
191
+ ## Step 10: Update the Hub
192
+
193
+ When new versions are released:
194
+
195
+ ```bash
196
+ cd ~/mep-hub/MEP
197
+ git pull origin main
198
+ docker-compose down
199
+ docker-compose build --no-cache
200
+ docker-compose up -d
201
+ ```
202
+
203
+ ---
204
+
205
+ ## Troubleshooting
206
+
207
+ ### 1. Docker Compose Fails
208
+ ```bash
209
+ # Check Docker daemon
210
+ sudo systemctl status docker
211
+
212
+ # Check logs
213
+ docker-compose logs
214
+ ```
215
+
216
+ ### 2. SSL Certificate Issues
217
+ ```bash
218
+ # Renew certificates
219
+ sudo certbot renew
220
+
221
+ # Check Nginx configuration
222
+ sudo nginx -t
223
+ ```
224
+
225
+ ### 3. WebSocket Connection Fails
226
+ - Ensure Nginx is properly configured with WebSocket support
227
+ - Check firewall rules
228
+ - Verify the Hub is running: `docker-compose ps`
229
+
230
+ ---
231
+
232
+ ## Security Notes
233
+
234
+ 1. **Backup the ledger database:**
235
+ ```bash
236
+ cp ~/mep-hub/MEP/hub_data/ledger.db ~/backup/
237
+ ```
238
+
239
+ 2. **Monitor logs for suspicious activity:**
240
+ ```bash
241
+ tail -f ~/mep-hub/MEP/hub_data/ledger_audit.log
242
+ ```
243
+
244
+ 3. **Keep the system updated:**
245
+ ```bash
246
+ sudo apt update && sudo apt upgrade -y
247
+ ```
248
+
249
+ ---
250
+
251
+ Your MEP Hub is now live and ready for bots to connect! 🚀
docker-compose.yml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ mep-hub:
5
+ build: ./hub
6
+ container_name: mep-hub
7
+ restart: always
8
+ ports:
9
+ - "8000:8000"
10
+ volumes:
11
+ - ./hub_data:/app/logs
12
+ - ./hub_data/ledger.db:/app/ledger.db
13
+ environment:
14
+ - TZ=UTC
hub/Dockerfile ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Install dependencies
6
+ COPY requirements.txt .
7
+ RUN pip install --no-cache-dir -r requirements.txt
8
+
9
+ # Copy source code
10
+ COPY . .
11
+
12
+ # Expose port
13
+ EXPOSE 8000
14
+
15
+ # Run Uvicorn
16
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
hub/requirements.txt CHANGED
@@ -1,3 +1,5 @@
1
  fastapi
2
  uvicorn
3
- pydantic
 
 
 
1
  fastapi
2
  uvicorn
3
+ pydantic
4
+ websockets
5
+ cryptography
hub_data/ledger.db ADDED
File without changes