All checks were successful
continuous-integration/drone/push Build is passing
- Dockerfile基础镜像切换到内网Harbor (192.168.195.25:19900) - .drone.yml registry从外网域名改为内网Harbor - Admin Dockerfile增加前端构建阶段(多阶段构建) - 新增基础镜像推送脚本 (push-base-images.ps1/sh) - 更新CI-CD部署文档
63 lines
2.3 KiB
PowerShell
63 lines
2.3 KiB
PowerShell
# ============================================================
|
|
# 一键推送基础镜像到内网 Harbor (Windows PowerShell)
|
|
# 用法: powershell -ExecutionPolicy Bypass -File scripts/push-base-images.ps1
|
|
# ============================================================
|
|
|
|
$HarborHost = "192.168.195.25:19900"
|
|
$HarborProject = "library"
|
|
|
|
# 需要推送的基础镜像: 外网地址 -> 内网路径
|
|
$Images = @(
|
|
@{ Src = "mcr.microsoft.com/dotnet/aspnet:10.0-preview"; Dst = "dotnet/aspnet:10.0-preview" },
|
|
@{ Src = "mcr.microsoft.com/dotnet/sdk:10.0-preview"; Dst = "dotnet/sdk:10.0-preview" },
|
|
@{ Src = "node:20-alpine"; Dst = "node:20-alpine" }
|
|
)
|
|
|
|
Write-Host "==========================================" -ForegroundColor Cyan
|
|
Write-Host " 推送基础镜像到内网 Harbor" -ForegroundColor Cyan
|
|
Write-Host " Harbor: $HarborHost" -ForegroundColor Cyan
|
|
Write-Host "==========================================" -ForegroundColor Cyan
|
|
|
|
# 登录 Harbor
|
|
Write-Host "`n[登录] Harbor $HarborHost" -ForegroundColor Yellow
|
|
docker login $HarborHost
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "登录失败,请检查用户名密码" -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
|
|
$Success = 0
|
|
$Fail = 0
|
|
|
|
foreach ($img in $Images) {
|
|
$src = $img.Src
|
|
$target = "$HarborHost/$HarborProject/$($img.Dst)"
|
|
|
|
Write-Host "`n------------------------------------------" -ForegroundColor Gray
|
|
Write-Host "[拉取] $src" -ForegroundColor Yellow
|
|
docker pull $src
|
|
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host "[标签] $target" -ForegroundColor Yellow
|
|
docker tag $src $target
|
|
|
|
Write-Host "[推送] $target" -ForegroundColor Yellow
|
|
docker push $target
|
|
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host "[完成] $($img.Dst)" -ForegroundColor Green
|
|
$Success++
|
|
} else {
|
|
Write-Host "[失败] 推送失败: $($img.Dst)" -ForegroundColor Red
|
|
$Fail++
|
|
}
|
|
} else {
|
|
Write-Host "[失败] 拉取失败: $src" -ForegroundColor Red
|
|
$Fail++
|
|
}
|
|
}
|
|
|
|
Write-Host "`n==========================================" -ForegroundColor Cyan
|
|
Write-Host " 完成: 成功 $Success, 失败 $Fail" -ForegroundColor Cyan
|
|
Write-Host "==========================================" -ForegroundColor Cyan
|