Files
Docker-Compose/Update-DockerStacks-n8n.ps1
MohandL3G 886878797d Updating DockerStack
Changed the RootPath of Update DockerStacks to Gitea
2026-02-12 17:15:24 +02:00

100 lines
3.3 KiB
PowerShell

# --- ADD TO TOP ---
# Start capturing all output (Write-Host, errors, etc.)
$FullLog = Start-Transcript -Path "$env:TEMP\docker_update_log.txt" -Force
# ------------------
# ==============================================================================
# CONFIGURATION
# ==============================================================================
$RootPath = "C:\Users\MohandL3G\Documents\Git\Docker-Compose"
$ServicesToUpdate = @(
"Cup",
"Gitea",
"Heimdall",
"Immich",
"Jellyfin",
"Jellyseerr",
"metube",
"n8n",
"Newt",
"Nextcloud",
"Nexterm",
"NPM",
"Portainer-CE",
"Zerobyte"
# "FutureApp"
)
# ==============================================================================
# EXECUTION LOGIC
# ==============================================================================
Write-Host "Starting Docker Stack Updates..." -ForegroundColor Cyan
Write-Host "--------------------------------" -ForegroundColor Gray
foreach ($Service in $ServicesToUpdate) {
$ServicePath = Join-Path -Path $RootPath -ChildPath $Service
if (Test-Path -Path $ServicePath) {
Write-Host "`n[$Service] Checking..." -ForegroundColor Yellow
Push-Location -Path $ServicePath
try {
# 1. PULL: Capture output but filter out the noisy progress bars
Write-Host "Pulling images..." -ForegroundColor Gray
# We filter out lines containing "Downloading", "Waiting", etc. to keep logs clean
$pullLog = docker compose --progress plain pull 2>&1 |
Where-Object { $_ -notmatch "Downloading|Waiting|Verifying|Pulling fs layer|Download complete" } |
Out-String
Write-Host $pullLog
# 2. UP: Force no-colors and capture the "Running/Recreated" status
$upLog = docker compose --ansi never up -d --remove-orphans --no-build 2>&1 | Out-String
Write-Host $upLog
Write-Host "[$Service] Done." -ForegroundColor Green
}
catch {
Write-Host "[$Service] ERROR: Something went wrong." -ForegroundColor Red
}
finally {
Pop-Location
}
}
else {
Write-Host "`n[$Service] WARNING: Folder not found at $ServicePath" -ForegroundColor Red
}
}
# ==============================================================================
# CLEANUP
# ==============================================================================
Write-Host "`n--------------------------------" -ForegroundColor Gray
Write-Host "Cleaning up unused images..." -ForegroundColor Yellow
# Redirection ensures the list of deleted IDs and space reclaimed is captured
$cleanupLog = docker image prune -f 2>&1 | Out-String
Write-Host $cleanupLog
Write-Host "Cleanup Complete." -ForegroundColor Green
Write-Host "All requested updates finished." -ForegroundColor Cyan
# --- ADD TO BOTTOM ---
Stop-Transcript
$LogContent = Get-Content "$env:TEMP\docker_update_log.txt" -Raw
# Send to n8n (Replace the URL with your actual n8n Webhook URL)
$WebhookUrl = "https://n8n.mohandl3g.ly/webhook/dockerupdater"
$Body = @{
status = "complete"
service = "DockerUpdater"
output = $LogContent
}
Invoke-RestMethod -Uri $WebhookUrl -Method Post -Body ($Body | ConvertTo-Json) -ContentType "application/json"
# ---------------------