# FLNXI Agent Go 版本构建脚本 param( [string]$Version = "1.0.0", [switch]$Push, [string]$ImageName = "registry.example.com/flnxi/agent" ) $ErrorActionPreference = "Stop" Write-Host "========================================" -ForegroundColor Cyan Write-Host " FLNXI Agent Go 构建脚本" -ForegroundColor Cyan Write-Host "========================================" -ForegroundColor Cyan Write-Host "" # 构建镜像 Write-Host "[1/3] 构建 Docker 镜像..." -ForegroundColor Yellow docker build -t "${ImageName}:${Version}" . if ($LASTEXITCODE -ne 0) { Write-Host "构建失败!" -ForegroundColor Red exit 1 } # 显示镜像大小 Write-Host "" Write-Host "[2/3] 镜像信息:" -ForegroundColor Yellow docker images $ImageName --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" # 推送镜像 if ($Push) { Write-Host "" Write-Host "[3/3] 推送到 Registry..." -ForegroundColor Yellow docker push "${ImageName}:${Version}" if ($LASTEXITCODE -eq 0) { Write-Host "" Write-Host "✅ 推送成功!" -ForegroundColor Green } } else { Write-Host "" Write-Host "跳过推送(使用 -Push 参数推送)" -ForegroundColor Gray } Write-Host "" Write-Host "========================================" -ForegroundColor Cyan Write-Host " 构建完成!" -ForegroundColor Green Write-Host "========================================" -ForegroundColor Cyan