package-deploy.ps1
1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# Relay Server 部署打包脚本
# 运行: .\package-deploy.ps1
$DeployDir = "$PSScriptRoot\deploy-package"
$ZipFile = "$PSScriptRoot\relay-server-deploy.zip"
Write-Host "=== 打包 Relay Server 部署文件 ===" -ForegroundColor Cyan
# 创建部署目录
if (Test-Path $DeployDir) { Remove-Item $DeployDir -Recurse -Force }
New-Item -ItemType Directory -Path $DeployDir | Out-Null
# 复制必要文件
$files = @(
".env",
"composer.json",
"docker-compose.yml",
"Dockerfile",
"migrate.php",
"start.php"
)
foreach ($file in $files) {
Copy-Item "$PSScriptRoot\$file" "$DeployDir\" -Force
Write-Host " + $file" -ForegroundColor Green
}
# 创建部署说明
$readme = @"
# Relay Server 部署指南
## 1. 上传整个目录到服务器
scp -r . user@server:/opt/moltbot-relay
## 2. 修改 .env 配置
- DB_HOST: 数据库地址
- DB_PASSWORD: 数据库密码
- REDIS_HOST: Redis 地址(使用 docker 内部网络可设为 redis)
## 3. 启动服务
cd /opt/moltbot-relay
docker-compose up -d --build
## 4. 查看日志
docker-compose logs -f
## 5. 开放防火墙
firewall-cmd --permanent --add-port=8888/tcp
firewall-cmd --reload
## 6. 修改本地插件配置
编辑 ~/.clawdbot/clawdbot.json:
{
"channels": {
"wechat": {
"enabled": true,
"relayUrl": "ws://服务器IP:8888"
}
}
}
"@
$readme | Set-Content "$DeployDir\README.md" -Encoding UTF8
# 打包成 zip
if (Test-Path $ZipFile) { Remove-Item $ZipFile -Force }
Compress-Archive -Path "$DeployDir\*" -DestinationPath $ZipFile
Write-Host ""
Write-Host "=== 打包完成 ===" -ForegroundColor Green
Write-Host "部署包: $ZipFile" -ForegroundColor Yellow
Write-Host ""
Write-Host "将 zip 文件上传到服务器后解压并运行 docker-compose up -d --build" -ForegroundColor White
# 清理临时目录
Remove-Item $DeployDir -Recurse -Force