55 lines
1.6 KiB
PowerShell
55 lines
1.6 KiB
PowerShell
# 本机构建并推送;服务器只 pull 镜像,无需源码
|
|
# 用法:
|
|
# $env:RECORD_BOT_IMAGE = "youruser/record-bot:1.0.1"
|
|
# .\deploy\build-push.ps1
|
|
# 可选同时构建自己的 gateway(一般用官方镜像即可):
|
|
# $env:GATEWAY_IMAGE = "youruser/weixin-ilink-gateway:latest"
|
|
# .\deploy\build-push.ps1 -IncludeGateway
|
|
|
|
param(
|
|
[switch]$IncludeGateway
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$root = Split-Path -Parent $PSScriptRoot
|
|
Set-Location $root
|
|
|
|
if (-not $env:RECORD_BOT_IMAGE) {
|
|
Write-Host @"
|
|
请先设置镜像名,例如:
|
|
`$env:RECORD_BOT_IMAGE = 'youruser/record-bot:latest'
|
|
.\deploy\build-push.ps1
|
|
"@
|
|
exit 1
|
|
}
|
|
|
|
Write-Host "=== Build record-bot → $($env:RECORD_BOT_IMAGE) ==="
|
|
docker build -t $env:RECORD_BOT_IMAGE -f record-bot/Dockerfile record-bot
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
|
|
Write-Host "=== Push $($env:RECORD_BOT_IMAGE) ==="
|
|
docker push $env:RECORD_BOT_IMAGE
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "Push 失败,先执行: docker login"
|
|
exit $LASTEXITCODE
|
|
}
|
|
|
|
if ($IncludeGateway) {
|
|
if (-not $env:GATEWAY_IMAGE) {
|
|
Write-Host "IncludeGateway 需要设置 GATEWAY_IMAGE"
|
|
exit 1
|
|
}
|
|
Write-Host "=== Build gateway → $($env:GATEWAY_IMAGE) ==="
|
|
docker build -t $env:GATEWAY_IMAGE -f weixin-ilink-gateway/Dockerfile weixin-ilink-gateway
|
|
docker push $env:GATEWAY_IMAGE
|
|
}
|
|
|
|
Write-Host @"
|
|
|
|
完成。服务器更新步骤(无源码):
|
|
docker compose -f deploy/record-bot.compose.yaml pull
|
|
docker compose -f deploy/record-bot.compose.yaml up -d
|
|
|
|
1Panel: 打开编排 → 拉取镜像 / 重建 即可。
|
|
"@
|