This repository has been archived by the owner on Apr 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
/
build-docker-images.ps1
50 lines (39 loc) · 1.78 KB
/
build-docker-images.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
42
43
44
45
46
47
48
49
50
Param(
[parameter(Mandatory=$false)][bool]$PublishToDockerHub=$false
)
# Taken from psake https://github.com/psake/psake
<#
.SYNOPSIS
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
to see if an error occcured. If an error is detected then an exception is thrown.
This function allows you to run command-line programs without having to
explicitly check the $lastexitcode variable.
.EXAMPLE
exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"
#>
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
$beatpulseversionentry = select-xml -Path .\build\dependencies.props -XPath "/Project/PropertyGroup[contains(@Label,'BeatPulse Package Versions')]/BeatPulseUIPackageVersion"
$tag = $beatpulseversionentry.node.InnerXML
#Building docker image
echo "building docker image with tag: $tag"
exec { & docker build . -f .\docker-images\BeatPulseUI-Image\Dockerfile -t xabarilcoding/beatpulseui:$tag }
exec { & docker tag xabarilcoding/beatpulseui:$tag xabarilcoding/beatpulseui:latest }
echo "Created docker image beatpulse:$tag. You can execute this image using docker run"
echo "Sample: docker run --name ui -p 5000:80 -e 'BeatPulse-UI:Liveness:0:Name=httpBasic' -e 'BeatPulse-UI:Liveness:0:Uri=http://www.google.es' -d beatpulseui:dev"
#Publish it
if($PublishToDockerHub){
docker push xabarilcoding/beatpulseui:$tag
docker push xabarilcoding/beatpulseui:latest
}