forked from Xabaril/AspNetCore.Diagnostics.HealthChecks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-docker-image.ps1
41 lines (29 loc) · 1.32 KB
/
build-docker-image.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Param(
[parameter(Mandatory=$false)][bool]$PublishToDockerHub=$false
)
function Exec
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd)
)
& $cmd
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
}
}
#Select the UI version from dependencies.props and use it as image version
$version = select-xml -Path .\build\dependencies.props -XPath "/Project/PropertyGroup[contains(@Label,'Health Checks Package Versions')]/HealthCheckUI"
$tag = $version.node.InnerXML
#Building docker image
echo "building docker image with tag: $tag"
exec { & docker build . -f .\build\docker-images\HealthChecks.UI.Image\Dockerfile -t xabarilcoding/healthchecksui:$tag }
exec { & docker tag xabarilcoding/healthchecksui:$tag xabarilcoding/healthchecksui:latest }
echo "Created docker image healthchecksui:$tag. You can execute this image using docker run"
echo "Sample: docker run --name ui -p 5000:80 -e 'HealthChecksUI:HealthChecks:0:Name=httpBasic' -e 'HealthChecksUI:HealthChecks:0:Uri=http://www.google.es' -d healthchecksui:dev"
#Publish it
if($PublishToDockerHub){
docker push xabarilcoding/healthchecksui:$tag
docker push xabarilcoding/healthchecksui:latest
}