114 lines
1.7 KiB
Markdown
114 lines
1.7 KiB
Markdown
# 快速部署指南
|
||
|
||
## 服务器端设置(一次性)
|
||
|
||
### 1. 克隆项目
|
||
|
||
```bash
|
||
git clone <your-gitea-repo-url> /opt/cloud-mcp
|
||
cd /opt/cloud-mcp
|
||
```
|
||
|
||
### 2. 配置环境变量
|
||
|
||
```bash
|
||
cp env.template .env
|
||
nano .env # 编辑配置
|
||
```
|
||
|
||
### 3. 设置脚本权限
|
||
|
||
```bash
|
||
chmod +x deploy.sh deploy-gitea.sh
|
||
```
|
||
|
||
### 4. 首次部署
|
||
|
||
```bash
|
||
./deploy.sh --rebuild
|
||
```
|
||
|
||
## Gitea Webhook 自动部署设置
|
||
|
||
### 方法一:使用 Git Hook(推荐)
|
||
|
||
```bash
|
||
# 在服务器上设置 post-receive hook
|
||
cd /opt/cloud-mcp
|
||
git config receive.denyCurrentBranch ignore
|
||
|
||
# 创建 hook 脚本
|
||
cat > .git/hooks/post-receive << 'EOF'
|
||
#!/bin/bash
|
||
cd /opt/cloud-mcp
|
||
git checkout -f
|
||
./deploy-gitea.sh
|
||
EOF
|
||
|
||
chmod +x .git/hooks/post-receive
|
||
```
|
||
|
||
### 方法二:使用 Gitea Webhook
|
||
|
||
1. 在 Gitea 仓库设置中添加 Webhook
|
||
2. URL: `http://your-server:port/hooks/deploy` (需要 webhook 服务器)
|
||
3. 或使用 SSH 方式触发部署脚本
|
||
|
||
## 日常使用
|
||
|
||
### 手动部署
|
||
|
||
```bash
|
||
# 在服务器上
|
||
cd /opt/cloud-mcp
|
||
./deploy-gitea.sh
|
||
```
|
||
|
||
### 查看状态
|
||
|
||
```bash
|
||
./deploy-gitea.sh --status
|
||
```
|
||
|
||
### 查看日志
|
||
|
||
```bash
|
||
./deploy-gitea.sh --logs
|
||
# 或
|
||
docker logs -f cloud-mcp
|
||
```
|
||
|
||
## 使用 Makefile(可选)
|
||
|
||
```bash
|
||
make deploy # 完整部署
|
||
make status # 查看状态
|
||
make logs # 查看日志
|
||
make restart # 重启
|
||
make down # 停止
|
||
make up # 启动
|
||
```
|
||
|
||
## 更新流程
|
||
|
||
1. **本地开发** → 提交代码 → 推送到 Gitea
|
||
2. **自动触发** → Webhook/Hook 自动运行 `deploy-gitea.sh`
|
||
3. **完成** → 容器自动更新并重启
|
||
|
||
## 故障排查
|
||
|
||
```bash
|
||
# 检查容器状态
|
||
docker ps -a | grep cloud-mcp
|
||
|
||
# 查看详细日志
|
||
docker logs cloud-mcp
|
||
|
||
# 检查部署日志
|
||
tail -f deploy.log
|
||
|
||
# 手动重启
|
||
./deploy-gitea.sh --restart
|
||
```
|
||
|