# Build Linux image on dev machine and export tar (Option C) # Usage: powershell -ExecutionPolicy Bypass -File deploy/build-image-local.ps1 $ErrorActionPreference = "Stop" $Root = Split-Path -Parent (Split-Path -Parent $MyInvocation.MyCommand.Path) $ImageTag = "yubao-app:latest" $OutTar = Join-Path $Root "deploy\yubao-app-image.tar" $Platform = "linux/amd64" Set-Location $Root if (-not (Get-Command docker -ErrorAction SilentlyContinue)) { throw "docker not found - start Docker Desktop first" } docker info *> $null if ($LASTEXITCODE -ne 0) { throw "Docker is not running" } Write-Host "build: platform=$Platform tag=$ImageTag" Write-Host "build: Next.js compile may take 5-15 minutes..." $env:DOCKER_BUILDKIT = '1' & docker build --platform $Platform -t $ImageTag -f Dockerfile . if ($LASTEXITCODE -ne 0) { throw "docker build failed" } if (Test-Path $OutTar) { Remove-Item -Force $OutTar } Write-Host "build: export -> $OutTar" & docker save $ImageTag -o $OutTar if ($LASTEXITCODE -ne 0) { throw "docker save failed" } $sizeMb = [math]::Round((Get-Item $OutTar).Length / 1MB, 1) Write-Host "" Write-Host "build: done size=${sizeMb}MB" Write-Host "upload deploy/yubao-app-image.tar to /home/project/yubao/deploy/" Write-Host "then on server: bash deploy/install-prebuilt-image.sh"