# Docker Build and Push Script # Builds the dashlio image and pushes it to private registry param( [string]$ImageName = "", [string]$RegistryUrl = "", [string]$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