Files
smom-dbis-138/scripts/deployment/go-live-z-ecosystem.ps1
zaragoza444 a2db92f3cb
Some checks failed
CI/CD Pipeline / Solidity Contracts (push) Failing after 1m14s
CI/CD Pipeline / Security Scanning (push) Successful in 2m34s
CI/CD Pipeline / Lint and Format (push) Failing after 40s
CI/CD Pipeline / Terraform Validation (push) Failing after 24s
CI/CD Pipeline / Kubernetes Validation (push) Successful in 26s
Deploy ChainID 138 / Deploy ChainID 138 (push) Failing after 37s
HYBX OMNL TypeScript & anchor / token-aggregation build + reconcile artifact (push) Failing after 22s
Validation / validate-genesis (push) Successful in 24s
Validation / validate-terraform (push) Failing after 24s
Validation / validate-kubernetes (push) Failing after 9s
Validation / validate-smart-contracts (push) Failing after 10s
Validation / validate-security (push) Failing after 1m22s
Validation / validate-documentation (push) Failing after 17s
Verify Deployment / Verify Deployment (push) Failing after 47s
feat: split Z Ecosystem from OMNL/DBIS with separate builds and deploy
Add VITE_ECOSYSTEM build profiles, Z-only nginx vhosts, standalone Z production stack script, and remove Z Chain from OMNL registry.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 05:17:40 -07:00

139 lines
5.3 KiB
PowerShell

# Go live — Z Ecosystem (production build + tunnel + deploy bundle)
$ErrorActionPreference = "Stop"
$Root = (Resolve-Path (Join-Path $PSScriptRoot "..\..")).Path
$LogDir = Join-Path $Root "logs"
$BundleDir = Join-Path $Root "dist\go-live"
$BundleTar = Join-Path $BundleDir "z-ecosystem-portal.tar.gz"
New-Item -ItemType Directory -Force -Path $LogDir, $BundleDir | Out-Null
function Import-DotEnvFile([string]$Path) {
if (-not (Test-Path $Path)) { return }
Get-Content $Path | ForEach-Object {
$line = $_.Trim()
if ($line -eq "" -or $line.StartsWith("#")) { return }
if ($line -match '^\s*([^=]+)=(.*)$') {
Set-Item -Path "env:$($matches[1].Trim())" -Value $matches[2].Trim().Trim('"').Trim("'")
}
}
}
function Stop-Port($port) {
$conn = Get-NetTCPConnection -LocalPort $port -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1
if ($conn -and $conn.OwningProcess) {
Stop-Process -Id $conn.OwningProcess -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 1
}
}
Set-Location $Root
Import-DotEnvFile (Join-Path $Root ".env")
Import-DotEnvFile (Join-Path $Root "config\z-ecosystem.local.env")
# Production frontend env (same-origin on zblockchainsystem.com)
$env:VITE_ECOSYSTEM = "z"
$env:VITE_TOKEN_AGGREGATION_URL = "/api/v1"
$env:VITE_SETTLEMENT_MIDDLEWARE_URL = "/settlement"
$env:VITE_DBIS_EXCHANGE_URL = "/exchange"
$env:VITE_ENABLE_Z_WALLET = "true"
$env:VITE_RPC_URL_900002 = if ($env:VITE_RPC_URL_900002) { $env:VITE_RPC_URL_900002 } else { "https://rpc.zblockchainsystem.com" }
$env:VITE_Z_CHAIN_EXPLORER_URL = if ($env:VITE_Z_CHAIN_EXPLORER_URL) { $env:VITE_Z_CHAIN_EXPLORER_URL } else { "https://explorer.zblockchainsystem.com" }
$env:VITE_Z_ECOSYSTEM_URL = if ($env:VITE_Z_ECOSYSTEM_URL) { $env:VITE_Z_ECOSYSTEM_URL } else { "https://zblockchainsystem.com" }
Remove-Item Env:VITE_OMNL_API_KEY -ErrorAction SilentlyContinue
Write-Host "=== 1/4 Local stack (Z Chain + APIs + portal) ==="
& "$PSScriptRoot\deploy-z-ecosystem.ps1"
Write-Host ""
Write-Host "=== 2/4 Production frontend build (Z-only) ==="
Set-Location "$Root\frontend-dapp"
npm run build:z
if ($LASTEXITCODE -ne 0) { throw "production frontend build failed" }
Write-Host ""
Write-Host "=== 3/4 Stage deploy bundle ==="
$stageRoot = Join-Path $BundleDir "stage"
if (Test-Path $stageRoot) { Remove-Item -Recurse -Force $stageRoot }
New-Item -ItemType Directory -Force -Path $stageRoot | Out-Null
$copyPaths = @(
"config",
"frontend-dapp\dist",
"packages\integration-foundation\package.json",
"packages\integration-foundation\dist",
"packages\settlement-core\package.json",
"packages\settlement-core\dist",
"services\token-aggregation\dist",
"services\token-aggregation\package.json",
"services\token-aggregation\package-lock.json",
"services\settlement-middleware\dist",
"services\settlement-middleware\package.json",
"services\settlement-middleware\package-lock.json",
"scripts\deployment\start-omnl-banking-portal.sh",
"scripts\deployment\deploy-z-ecosystem-production.sh",
"deploy\nginx\omnl-lxc-portal.conf",
"deploy\nginx\omnl-portal-auth-current.conf.inc"
)
foreach ($rel in $copyPaths) {
$src = Join-Path $Root $rel
if (-not (Test-Path $src)) {
Write-Host " skip missing: $rel"
continue
}
$dst = Join-Path $stageRoot $rel
New-Item -ItemType Directory -Force -Path (Split-Path $dst -Parent) | Out-Null
Copy-Item -Path $src -Destination $dst -Recurse -Force
}
if (Get-Command tar -ErrorAction SilentlyContinue) {
if (Test-Path $BundleTar) { Remove-Item -Force $BundleTar }
tar -czf $BundleTar -C $stageRoot .
Write-Host " bundle: $BundleTar"
} else {
Write-Host " tar not found - bundle folder: $stageRoot"
}
Write-Host ""
Write-Host "=== 4/4 Public tunnel (cloudflared) ==="
Stop-Port 4040
$tunnelLog = Join-Path $LogDir "cloudflared-z-ecosystem.log"
$cf = "C:\Program Files (x86)\cloudflared\cloudflared.exe"
if (-not (Test-Path $cf)) { $cf = "cloudflared" }
$tunnelErr = Join-Path $LogDir "cloudflared-z-ecosystem.err.log"
Start-Process -FilePath "cmd.exe" -ArgumentList @("/c", "`"$cf`" tunnel --url http://localhost:3002 --metrics localhost:4040 > `"$tunnelLog`" 2> `"$tunnelErr`"") `
-WindowStyle Hidden
$tunnelUrl = $null
for ($i = 0; $i -lt 30; $i++) {
Start-Sleep -Seconds 1
if (Test-Path $tunnelLog) {
$log = Get-Content $tunnelLog -Raw -ErrorAction SilentlyContinue
if ($log -match '(https://[a-z0-9-]+\.trycloudflare\.com)') {
$tunnelUrl = $matches[1]
break
}
}
}
Write-Host ""
Write-Host "Z Ecosystem GO LIVE"
Write-Host "==================="
if ($tunnelUrl) {
Write-Host " Public tunnel: $tunnelUrl/z"
Write-Host " Z Wallet: $tunnelUrl/z-wallet"
Write-Host " Z Bot health: $tunnelUrl/api/v1/z-bot/health"
} else {
Write-Host " Tunnel starting - see $tunnelLog"
Write-Host " Local: http://localhost:3002/z"
}
Write-Host ""
Write-Host "Production portal zblockchainsystem.com - run on dev-bis-ali:"
Write-Host ' cd ~/smom-dbis-138; git pull; bash scripts/deployment/deploy-z-ecosystem-production.sh'
Write-Host ' # or push bundle to LXC:'
Write-Host ' Z_ECOSYSTEM_PUSH_PCT=1 bash scripts/deployment/deploy-z-ecosystem-production.sh'
Write-Host ""
Write-Host "DNS still required for Z Chain RPC:"
Write-Host ' rpc.zblockchainsystem.com -> Besu host port 8546'
Write-Host ' explorer.zblockchainsystem.com -> explorer optional'