Skip to content

Commit 9af21ab

Browse files
author
cw
committed
feat: add Coolify deployment configuration
- Add capability CDN Dockerfile and nginx config - Add telemetry API Dockerfile and Node.js server - Add deployment automation scripts - Add comprehensive deployment documentation
1 parent 9250045 commit 9af21ab

18 files changed

+2414
-0
lines changed

cloud/.env.example

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# GitHub Configuration
2+
GITHUB_TOKEN=ghp_your_github_token_here
3+
GITHUB_OWNER=ai-dashboad
4+
GITHUB_REPO=opencli
5+
6+
# API Configuration
7+
PORT=3000
8+
9+
# Optional: If using different Coolify instance
10+
# COOLIFY_URL=https://cicd.dtok.io

cloud/.gitignore

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Environment files
2+
.env
3+
.env.local
4+
5+
# Node modules
6+
node_modules/
7+
package-lock.json
8+
9+
# Build artifacts
10+
dist/
11+
build/
12+
13+
# Docker volumes
14+
volumes/
15+
16+
# Logs
17+
*.log
18+
logs/

cloud/COOLIFY_QUICK_START.md

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,218 @@
1+
# Coolify 5分钟快速部署
2+
3+
## 前提
4+
5+
- ✅ 仓库: https://github.com/ai-dashboad/opencli
6+
- ✅ Coolify: https://cicd.dtok.io
7+
- ✅ GitHub Token (从 https://github.com/settings/tokens 获取)
8+
9+
---
10+
11+
## 🚀 步骤一:部署 CDN (2分钟)
12+
13+
### 1. 打开 Coolify
14+
访问 https://cicd.dtok.io
15+
16+
### 2. 新建应用
17+
点击 **`+ New Resource`****`Application`**
18+
19+
### 3. 选择源
20+
```
21+
Source Type: [x] Public Repository (GitHub)
22+
Repository URL: https://github.com/ai-dashboad/opencli
23+
Branch: main
24+
```
25+
26+
### 4. 构建设置
27+
```
28+
Build Pack: [x] Dockerfile
29+
Dockerfile Location: cloud/capability-cdn/Dockerfile
30+
Base Directory: /
31+
Docker Build Context: /
32+
```
33+
34+
### 5. 网络设置
35+
```
36+
Port: 80
37+
Publicly Accessible: [x] Yes
38+
Domain: opencli.ai
39+
Path Prefix: /api/capabilities
40+
```
41+
42+
### 6. 启用自动部署
43+
```
44+
[x] Automatic Deployment
45+
```
46+
勾选后,每次推送到 main 分支时自动部署。
47+
48+
### 7. 点击 Deploy
49+
等待 2-3 分钟构建完成。
50+
51+
### 8. 验证
52+
访问: https://opencli.ai/health
53+
应该显示: `OK`
54+
55+
---
56+
57+
## 🔔 步骤二:部署 API (3分钟)
58+
59+
### 1. 再次新建应用
60+
点击 **`+ New Resource`****`Application`**
61+
62+
### 2. 选择源
63+
```
64+
Source Type: [x] Public Repository (GitHub)
65+
Repository URL: https://github.com/ai-dashboad/opencli
66+
Branch: main
67+
```
68+
69+
### 3. 构建设置
70+
```
71+
Build Pack: [x] Dockerfile
72+
Dockerfile Location: cloud/telemetry-api/Dockerfile
73+
Base Directory: /cloud/telemetry-api
74+
Docker Build Context: /cloud/telemetry-api
75+
```
76+
77+
### 4. 环境变量(重要!)
78+
点击 **`Environment Variables`** 标签,添加:
79+
80+
| Key | Value | Secret? |
81+
|-----|-------|---------|
82+
| `GITHUB_TOKEN` | `ghp_你的token` ||
83+
| `GITHUB_OWNER` | `ai-dashboad` ||
84+
| `GITHUB_REPO` | `opencli` ||
85+
| `PORT` | `3000` ||
86+
87+
### 5. 网络设置
88+
```
89+
Port: 3000
90+
Publicly Accessible: [x] Yes
91+
Domain: opencli.ai
92+
Path Prefix: /api/telemetry
93+
```
94+
95+
### 6. 启用自动部署
96+
```
97+
[x] Automatic Deployment
98+
```
99+
100+
### 7. 点击 Deploy
101+
等待 3-5 分钟构建完成。
102+
103+
### 8. 验证
104+
访问: https://opencli.ai/api/telemetry/health
105+
应该显示: `{"status":"ok",...}`
106+
107+
---
108+
109+
## ✅ 验证部署成功
110+
111+
### 测试 CDN
112+
```bash
113+
curl https://opencli.ai/health
114+
curl https://opencli.ai/api/capabilities/manifest.json
115+
```
116+
117+
### 测试 API
118+
```bash
119+
# 健康检查
120+
curl https://opencli.ai/api/telemetry/health
121+
122+
# 测试错误上报
123+
curl -X POST https://opencli.ai/api/telemetry/report \
124+
-H "Content-Type: application/json" \
125+
-d '{
126+
"error": {"message": "Test from Coolify deployment"},
127+
"system_info": {"platform": "test"},
128+
"device_id": "test-123"
129+
}'
130+
```
131+
132+
检查 GitHub Issues,应该会看到自动创建的 Issue。
133+
134+
---
135+
136+
## 🔄 自动部署工作流
137+
138+
部署完成后:
139+
140+
```
141+
你推送代码到 GitHub
142+
143+
GitHub 触发 webhook
144+
145+
Coolify 接收通知
146+
147+
自动拉取最新代码
148+
149+
重新构建 Docker 镜像
150+
151+
零停机部署
152+
153+
完成!
154+
```
155+
156+
**无需手动操作,全自动!**
157+
158+
---
159+
160+
## 📊 监控和日志
161+
162+
### 查看日志
163+
在 Coolify 中:
164+
1. 进入应用详情页
165+
2. 点击 **`Logs`** 标签
166+
3. 实时查看日志
167+
168+
### 查看状态
169+
在应用列表中可以看到:
170+
- ✅ 运行状态
171+
- 📊 资源使用
172+
- 🔄 最后部署时间
173+
174+
---
175+
176+
## 🎯 常见问题
177+
178+
### Q: 构建失败怎么办?
179+
**A:** 在 Coolify 中查看构建日志,常见原因:
180+
- Dockerfile 路径错误
181+
- 依赖安装失败
182+
- 端口冲突
183+
184+
### Q: 域名无法访问?
185+
**A:** 检查:
186+
1. DNS 是否指向 Coolify 服务器
187+
2. Coolify Proxy 是否运行
188+
3. SSL 证书是否配置
189+
190+
### Q: 如何手动触发重新部署?
191+
**A:** 在应用详情页点击 **`Redeploy`** 按钮
192+
193+
### Q: 如何回滚到之前的版本?
194+
**A:** Coolify 会保留历史部署,可以在部署历史中选择回滚
195+
196+
---
197+
198+
## 📝 配置参考
199+
200+
完整配置保存在:
201+
- `cloud/coolify.yaml` - 配置文件
202+
- `cloud/docker-compose.yml` - Docker Compose 配置
203+
- `cloud/DEPLOYMENT_CHECKLIST.md` - 详细检查清单
204+
205+
---
206+
207+
## 🎉 完成!
208+
209+
现在你的 OpenCLI 云端服务已经部署完成,并且会自动更新!
210+
211+
每次你推送代码到 `main` 分支,Coolify 会自动:
212+
1. 拉取最新代码
213+
2. 重新构建
214+
3. 部署新版本
215+
4. 健康检查
216+
5. 完成
217+
218+
**零人工干预,全自动化!** 🚀

0 commit comments

Comments
 (0)