52 lines
1.7 KiB
PowerShell
52 lines
1.7 KiB
PowerShell
# Build and push the production web image to Gitea over LAN (fast path).
|
|
param(
|
|
[string]$Tag = "latest",
|
|
[switch]$SkipHosts,
|
|
[switch]$SkipBuild
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
. (Join-Path $PSScriptRoot "..\scripts\lib\Deploy-CliResult.ps1")
|
|
|
|
$Registry = "gitea.mysuperlab.netcraze.pro"
|
|
$Image = "$Registry/danilka/gallery-web"
|
|
|
|
function Test-DockerRunning {
|
|
$prevEap = $ErrorActionPreference
|
|
$ErrorActionPreference = 'Continue'
|
|
docker info 2>&1 | Out-Null
|
|
$ok = $LASTEXITCODE -eq 0
|
|
$ErrorActionPreference = $prevEap
|
|
return $ok
|
|
}
|
|
|
|
Write-Host "=== Build + LAN push to Gitea ===" -ForegroundColor Cyan
|
|
|
|
if (-not (Test-DockerRunning)) {
|
|
Write-DeployCliResult -Script 'build-push-lan' -Success $false -Summary 'Docker is not running. Start Docker Desktop and retry.'
|
|
exit 1
|
|
}
|
|
|
|
if (-not $SkipBuild) {
|
|
Write-Host ""
|
|
Write-Host "Building ${Image}:${Tag} ..."
|
|
docker build -f infra/docker/Dockerfile -t "${Image}:${Tag}" .
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-DeployCliResult -Script 'build-push-lan' -Success $false -Summary "Docker build failed with exit code $LASTEXITCODE"
|
|
exit $LASTEXITCODE
|
|
}
|
|
Write-Host "Build complete." -ForegroundColor Green
|
|
} else {
|
|
Write-Host "Skipping build (-SkipBuild)." -ForegroundColor Yellow
|
|
}
|
|
|
|
Write-Host ""
|
|
& "$PSScriptRoot/push-lan.ps1" -Tag $Tag -SkipHosts:$SkipHosts
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-DeployCliResult -Script 'build-push-lan' -Success $false -Summary "Docker push failed with exit code $LASTEXITCODE"
|
|
exit $LASTEXITCODE
|
|
}
|
|
|
|
Write-DeployCliResult -Script 'build-push-lan' -Success $true -Summary 'Docker image built and pushed to Gitea.' -Details @("Image: ${Image}:${Tag}")
|
|
exit 0
|