Files
OrchestrAD/scripts/build.ps1
T
GraceSolutions 09a09d4a68 feat: Initial backend scaffold - Go service, database, CLI, API structure
Phase 1 foundations:
- Go backend with Chi router framework
- SQLite database with WAL mode and foreign keys
- Database migrations for users, roles, credentials, AD connections, schedules, rules, and audit
- CLI commands: init, run, install, uninstall, start, stop, migrate, backup, restore, doctor
- Configuration loading from environment variables
- Centralized logging with file rotation (lumberjack)
- Crypto package for Argon2id password hashing and AES-GCM encryption
- Auth service with session management
- Audit service for event logging
- Scheduler with 6-field cron support
- REST API routes scaffolded for all major resources
- CORS support with localhost defaults for development
- Docker support with Dockerfile and docker-compose.yml
- Multi-platform build script (PowerShell)
- Project structure per design specification

Version format: yyyy.MM.dd.HHmm
All PKs are UUIDv4, all timestamps UTC
2026-04-19 10:07:21 -04:00

118 lines
3.9 KiB
PowerShell

# OrchestrAD Build Script
# Builds for Windows, macOS, and Linux (amd64 and arm64)
# Version format: yyyy.MM.dd.HHmm
param(
[switch]$All,
[switch]$Windows,
[switch]$MacOS,
[switch]$Linux,
[switch]$Clean
)
$ErrorActionPreference = "Stop"
# Version generation
$Version = Get-Date -Format "yyyy.MM.dd.HHmm"
$BuildTime = Get-Date -Format "yyyy-MM-ddTHH:mm:ssZ"
$GitCommit = git rev-parse --short HEAD 2>$null
if (-not $GitCommit) { $GitCommit = "unknown" }
Write-Host "Building OrchestrAD v$Version" -ForegroundColor Cyan
Write-Host "Build Time: $BuildTime"
Write-Host "Git Commit: $GitCommit"
$ProjectRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
if (-not (Test-Path "$ProjectRoot\backend")) {
$ProjectRoot = Split-Path -Parent $PSScriptRoot
}
$BackendDir = Join-Path $ProjectRoot "backend"
$BinariesDir = Join-Path $ProjectRoot "binaries"
$ResourcesDir = Join-Path $ProjectRoot "resources"
# Clean binaries directory if requested
if ($Clean) {
Write-Host "Cleaning binaries directory..." -ForegroundColor Yellow
if (Test-Path $BinariesDir) {
Remove-Item -Recurse -Force $BinariesDir
}
}
# Create output directories
$Platforms = @(
@{ OS = "windows"; Arch = "amd64"; Ext = ".exe" },
@{ OS = "windows"; Arch = "arm64"; Ext = ".exe" },
@{ OS = "darwin"; Arch = "amd64"; Ext = "" },
@{ OS = "darwin"; Arch = "arm64"; Ext = "" },
@{ OS = "linux"; Arch = "amd64"; Ext = "" },
@{ OS = "linux"; Arch = "arm64"; Ext = "" }
)
# Filter platforms based on flags
if (-not $All) {
if ($Windows) {
$Platforms = $Platforms | Where-Object { $_.OS -eq "windows" }
} elseif ($MacOS) {
$Platforms = $Platforms | Where-Object { $_.OS -eq "darwin" }
} elseif ($Linux) {
$Platforms = $Platforms | Where-Object { $_.OS -eq "linux" }
} else {
# Default to all platforms
$All = $true
}
}
# LDFlags for version injection
$LDFlags = "-s -w -X github.com/Grace-Solutions/OrchestrAD/internal/version.Version=$Version -X github.com/Grace-Solutions/OrchestrAD/internal/version.BuildTime=$BuildTime -X github.com/Grace-Solutions/OrchestrAD/internal/version.GitCommit=$GitCommit"
Push-Location $BackendDir
try {
foreach ($Platform in $Platforms) {
$OS = $Platform.OS
$Arch = $Platform.Arch
$Ext = $Platform.Ext
# Map darwin to macos for folder naming
$FolderOS = if ($OS -eq "darwin") { "macos" } else { $OS }
$OutputDir = Join-Path $BinariesDir "$FolderOS\$Arch"
$OutputFile = Join-Path $OutputDir "orchestrad$Ext"
# Create output directory
if (-not (Test-Path $OutputDir)) {
New-Item -ItemType Directory -Path $OutputDir -Force | Out-Null
}
Write-Host "`nBuilding for $OS/$Arch..." -ForegroundColor Green
$env:GOOS = $OS
$env:GOARCH = $Arch
$env:CGO_ENABLED = "1"
# For cross-compilation, CGO needs special handling
if ($OS -ne "windows" -and $env:OS -eq "Windows_NT") {
$env:CGO_ENABLED = "0"
Write-Host " Note: CGO disabled for cross-compilation (SQLite will use pure Go driver)" -ForegroundColor Yellow
}
go build -ldflags "$LDFlags" -o "$OutputFile" ./cmd/orchestrad
if ($LASTEXITCODE -eq 0) {
$FileSize = (Get-Item $OutputFile).Length / 1MB
Write-Host " Built: $OutputFile ($([math]::Round($FileSize, 2)) MB)" -ForegroundColor Green
} else {
Write-Host " Failed to build for $OS/$Arch" -ForegroundColor Red
}
}
} finally {
Pop-Location
Remove-Item Env:GOOS -ErrorAction SilentlyContinue
Remove-Item Env:GOARCH -ErrorAction SilentlyContinue
Remove-Item Env:CGO_ENABLED -ErrorAction SilentlyContinue
}
Write-Host "`nBuild complete!" -ForegroundColor Cyan
Write-Host "Binaries are in: $BinariesDir"