Add docker and build scripts
Some checks failed
ci / ci (22, ubuntu-latest) (push) Has been cancelled
Some checks failed
ci / ci (22, ubuntu-latest) (push) Has been cancelled
This commit is contained in:
58
docker-build.example.ps1
Normal file
58
docker-build.example.ps1
Normal 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
|
||||
Reference in New Issue
Block a user