Add docker and build scripts
Some checks failed
ci / ci (22, ubuntu-latest) (push) Has been cancelled

This commit is contained in:
2026-04-29 10:01:33 +01:00
parent 08bb142c0a
commit 7fa65a9ee3
4 changed files with 94 additions and 0 deletions

58
docker-build.example.ps1 Normal file
View File

@@ -0,0 +1,58 @@
# Docker Build and Push Script
# Builds the dashlio image and pushes it to private registry
param(
[string]$ImageName = "<imageName>",
[string]$RegistryUrl = "<registryUrl>",
[string]$Tag = "<tag>",
[string]$Dockerfile = "Dockerfile",
[string]$BuildContext = "."
)
# Colors for output
$ErrorColor = "Red"
$SuccessColor = "Green"
$InfoColor = "Cyan"
Write-Host "Docker Build and Push Script" -ForegroundColor $InfoColor
Write-Host "======================================" -ForegroundColor $InfoColor
# Variables
$FullImageName = "$RegistryUrl/$ImageName"
$TaggedImage = "$FullImageName" + ":$Tag"
Write-Host "Registry: $RegistryUrl" -ForegroundColor $InfoColor
Write-Host "Image Name: $ImageName" -ForegroundColor $InfoColor
Write-Host "Tag: $Tag" -ForegroundColor $InfoColor
Write-Host "Full Image: $TaggedImage" -ForegroundColor $InfoColor
Write-Host "Dockerfile: $Dockerfile" -ForegroundColor $InfoColor
Write-Host "Context: $BuildContext" -ForegroundColor $InfoColor
Write-Host "======================================" -ForegroundColor $InfoColor
Write-Host ""
# Step 1: Build the image
Write-Host "Step 1: Building Docker image..." -ForegroundColor $InfoColor
docker build -f $Dockerfile -t $TaggedImage $BuildContext
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: Docker build failed!" -ForegroundColor $ErrorColor
exit 1
}
Write-Host "Build successful!" -ForegroundColor $SuccessColor
Write-Host ""
# Step 2: Push the image
Write-Host "Step 2: Pushing image to registry..." -ForegroundColor $InfoColor
docker push $TaggedImage
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: Docker push failed!" -ForegroundColor $ErrorColor
exit 1
}
Write-Host "Push successful!" -ForegroundColor $SuccessColor
Write-Host ""
Write-Host "======================================" -ForegroundColor $SuccessColor
Write-Host "Image $TaggedImage is ready!" -ForegroundColor $SuccessColor
Write-Host "======================================" -ForegroundColor $SuccessColor