#!/usr/bin/env pwsh # Local convenience: build the multi-arch MeterVault image and push it. # Usage: ./deploy/build-and-push.ps1 -Registry ghcr.io -Image finalfactory/metervault # Version is read from the VERSION file; images are tagged : and :latest. param( [string]$Registry = "ghcr.io", [string]$Image = "finalfactory/metervault", [string[]]$Platforms = @("linux/amd64", "linux/arm64"), [switch]$Push ) $ErrorActionPreference = "Stop" $root = Split-Path -Parent $PSScriptRoot $version = (Get-Content (Join-Path $root "VERSION")).Trim() $ref = "$Registry/$Image" Write-Host "Building $ref:$version ($($Platforms -join ', '))" -ForegroundColor Cyan $args = @( "buildx", "build", "--platform", ($Platforms -join ","), "-f", (Join-Path $root "deploy/Dockerfile"), "-t", "$ref`:$version", "-t", "$ref`:latest" ) if ($Push) { $args += "--push" } else { $args += "--load" } $args += $root & docker @args if ($LASTEXITCODE -ne 0) { throw "docker buildx build failed" } Write-Host "Done." -ForegroundColor Green