chore: 并入 iotlcm-onelink-mock 历史到 onelink-mock/(原提交 f398595)

This commit is contained in:
MiFaZhan
2026-11-02 13:28:02 +08:00
64 changed files with 10585 additions and 0 deletions
+64
View File
@@ -0,0 +1,64 @@
param(
[Parameter(Mandatory = $true)]
[string]$Registry,
[string]$Namespace = 'iotlcm',
[string]$Tag = 'latest',
[string]$Username = $env:REGISTRY_USERNAME
)
$ErrorActionPreference = 'Stop'
$ProjectRoot = Resolve-Path (Join-Path $PSScriptRoot '..')
$Password = $env:REGISTRY_PASSWORD
if (-not [string]::IsNullOrWhiteSpace($Username) -and [string]::IsNullOrWhiteSpace($Password)) {
throw 'REGISTRY_PASSWORD is required when REGISTRY_USERNAME is set.'
}
function Invoke-Docker {
param(
[Parameter(Mandatory = $true)]
[string[]]$Arguments
)
& docker @Arguments
if ($LASTEXITCODE -ne 0) {
throw "docker $($Arguments -join ' ') failed with exit code $LASTEXITCODE"
}
}
$backendImage = "$Registry/$Namespace/onelink-mock-backend:$Tag"
$frontendImage = "$Registry/$Namespace/onelink-mock-frontend:$Tag"
Push-Location $ProjectRoot
try {
if (-not [string]::IsNullOrWhiteSpace($Username)) {
Write-Host "Logging in to $Registry..."
$Password | & docker login $Registry --username $Username --password-stdin
if ($LASTEXITCODE -ne 0) {
throw "docker login failed with exit code $LASTEXITCODE"
}
}
Write-Host "Building backend image: $backendImage"
Invoke-Docker @('build', '-t', $backendImage, '.')
Write-Host "Pushing backend image: $backendImage"
Invoke-Docker @('push', $backendImage)
Push-Location (Join-Path $ProjectRoot 'frontend')
try {
Write-Host "Building frontend image: $frontendImage"
Invoke-Docker @('build', '-t', $frontendImage, '.')
Write-Host "Pushing frontend image: $frontendImage"
Invoke-Docker @('push', $frontendImage)
} finally {
Pop-Location
}
Write-Host 'Image build and push completed.' -ForegroundColor Green
Write-Host " $backendImage"
Write-Host " $frontendImage"
} finally {
Pop-Location
}