🚧 WIP
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Starts the mqtt-ingester stack on local Docker.
|
||||
|
||||
.DESCRIPTION
|
||||
Loads .env (values already set in the environment take precedence),
|
||||
verifies that the certificate files exist, then runs docker compose up
|
||||
with the requested profiles.
|
||||
|
||||
.PARAMETER Profiles
|
||||
Comma-separated compose profiles to enable (e.g. "telemetry").
|
||||
|
||||
.EXAMPLE
|
||||
.\scripts\start.ps1
|
||||
.\scripts\start.ps1 -Profiles telemetry
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$Profiles = ""
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# Stack root = parent of the scripts directory.
|
||||
$StackRoot = Split-Path -Parent $PSScriptRoot
|
||||
Set-Location $StackRoot
|
||||
|
||||
if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
|
||||
Write-Error "docker not found in PATH"
|
||||
}
|
||||
|
||||
# Load .env if present; existing environment variables win.
|
||||
if (Test-Path ".env") {
|
||||
Get-Content ".env" | ForEach-Object {
|
||||
$line = $_.Trim()
|
||||
if ($line -and -not $line.StartsWith("#")) {
|
||||
$parts = $line -split "=", 2
|
||||
if ($parts.Length -eq 2) {
|
||||
$name = $parts[0].Trim()
|
||||
if (-not (Test-Path "Env:$name")) {
|
||||
Set-Item -Path "Env:$name" -Value $parts[1].Trim()
|
||||
}
|
||||
}
|
||||
else {
|
||||
Write-Warning "Ignoring malformed .env line: $line"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Required certificates (see README).
|
||||
$requiredCerts = @("ca.crt", "client.crt", "client.key", "server.crt", "server.key")
|
||||
$missing = @()
|
||||
foreach ($cert in $requiredCerts) {
|
||||
if (-not (Test-Path (Join-Path "certs" $cert))) {
|
||||
$missing += $cert
|
||||
}
|
||||
}
|
||||
if ($missing.Count -gt 0) {
|
||||
Write-Warning "Missing certificates in certs/: $($missing -join ', ')"
|
||||
Write-Warning "The API will fail to start. See the 'Certificates' section of README.md."
|
||||
}
|
||||
|
||||
# MQTT_BROKER_HOST must be defined somewhere.
|
||||
if (-not $env:MQTT_BROKER_HOST) {
|
||||
Write-Warning "MQTT_BROKER_HOST is not set; mqtt-client will exit with an error."
|
||||
}
|
||||
|
||||
$composeArgs = @("compose", "up", "-d", "--build")
|
||||
if ($Profiles) {
|
||||
$composeArgs += @("--profile", $Profiles)
|
||||
}
|
||||
|
||||
Write-Host "Starting stack..." -ForegroundColor Cyan
|
||||
docker @composeArgs
|
||||
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
||||
|
||||
Write-Host ""
|
||||
Write-Host "Services:" -ForegroundColor Cyan
|
||||
docker compose ps
|
||||
Write-Host ""
|
||||
Write-Host "Web UI: http://localhost:8080 (default login admin/admin)" -ForegroundColor Green
|
||||
Write-Host "API: https://localhost:8443 (mTLS or session cookie)" -ForegroundColor Green
|
||||
Write-Host "Logs: docker compose logs -f <service>" -ForegroundColor Gray
|
||||
Reference in New Issue
Block a user