81 lines
2.7 KiB
PowerShell
81 lines
2.7 KiB
PowerShell
#!/usr/bin/env pwsh
|
|
# build-docker.ps1 - Build and run the restreamer-ui-v2 Docker image
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$ProjectDir = $PSScriptRoot
|
|
$ImageName = "restreamer-ui-v2"
|
|
$Tag = "latest"
|
|
$LogFile = "$ProjectDir\docker-build.log"
|
|
|
|
Write-Host "=== Building Docker image: ${ImageName}:${Tag} ===" -ForegroundColor Cyan
|
|
Write-Host "Project dir: $ProjectDir"
|
|
Write-Host "Log file: $LogFile"
|
|
Write-Host ""
|
|
|
|
Set-Location $ProjectDir
|
|
|
|
# Build
|
|
$buildOutput = docker build `
|
|
--tag "${ImageName}:${Tag}" `
|
|
--file "$ProjectDir\Dockerfile" `
|
|
--progress plain `
|
|
"$ProjectDir" 2>&1
|
|
|
|
$buildOutput | Out-File -FilePath $LogFile -Encoding utf8
|
|
$buildOutput | Write-Host
|
|
|
|
if ($LASTEXITCODE -ne 0) {
|
|
Write-Host "`n=== BUILD FAILED (exit $LASTEXITCODE) ===" -ForegroundColor Red
|
|
Write-Host "See log: $LogFile"
|
|
exit $LASTEXITCODE
|
|
}
|
|
|
|
Write-Host "`n=== BUILD SUCCEEDED ===" -ForegroundColor Green
|
|
|
|
# Show image size
|
|
docker images "${ImageName}:${Tag}"
|
|
|
|
# ── Ask user if they want to run ──────────────────────────────────────────────
|
|
$run = Read-Host "`nRun container now? [Y/n]"
|
|
if ($run -eq '' -or $run -match '^[Yy]') {
|
|
|
|
# Stop existing container if running
|
|
$existing = docker ps -a --filter "name=restreamer-ui-test" --format "{{.ID}}" 2>&1
|
|
if ($existing) {
|
|
Write-Host "Stopping existing container..." -ForegroundColor Yellow
|
|
docker stop restreamer-ui-test 2>&1 | Out-Null
|
|
docker rm restreamer-ui-test 2>&1 | Out-Null
|
|
}
|
|
|
|
Write-Host "`nStarting container on http://localhost:3000 ..." -ForegroundColor Cyan
|
|
Write-Host "Environment:"
|
|
Write-Host " CORE_ADDRESS = https://restreamer.nextream.sytes.net"
|
|
Write-Host " YTDLP_HOST = 192.168.1.20:8282"
|
|
Write-Host " FB_SERVER_URL = http://localhost:3000/fb-server"
|
|
Write-Host ""
|
|
|
|
docker run -d `
|
|
--name restreamer-ui-test `
|
|
--restart unless-stopped `
|
|
-p 3000:3000 `
|
|
-e CORE_ADDRESS="https://restreamer.nextream.sytes.net" `
|
|
-e YTDLP_HOST="192.168.1.20:8282" `
|
|
-e YTDLP_URL="http://localhost:3000/yt-stream" `
|
|
-e FB_SERVER_URL="http://localhost:3000/fb-server" `
|
|
-e FB_ENCRYPTION_SECRET="restreamer-ui-fb-secret-key-32x!" `
|
|
-v "restreamer-ui-fb-data:/data/fb" `
|
|
"${ImageName}:${Tag}"
|
|
|
|
if ($LASTEXITCODE -eq 0) {
|
|
Write-Host "`n=== Container started ===" -ForegroundColor Green
|
|
Write-Host "UI: http://localhost:3000/ui/"
|
|
Write-Host ""
|
|
Write-Host "Logs (Ctrl+C to stop watching):"
|
|
docker logs -f restreamer-ui-test
|
|
} else {
|
|
Write-Host "Failed to start container." -ForegroundColor Red
|
|
exit 1
|
|
}
|
|
}
|
|
|