-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-run.ps1
51 lines (39 loc) · 1.04 KB
/
build-run.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
(
$version
)
Write-Host $version
go mod download
Write-Host "Script:" $PSCommandPath
Write-Host "Path:" $PSScriptRoot
Set-Location -Path $PSScriptRoot
function Run-Script
{
param([string]$script)
$ScriptPath = "$PSScriptRoot\$script.ps1"
& $ScriptPath
}
$Time = [System.Diagnostics.Stopwatch]::StartNew()
function PrintElapsedTime {
Log $([string]::Format("Elapsed time: {0}.{1}", $Time.Elapsed.Seconds, $Time.Elapsed.Milliseconds))
}
function Log {
Param ([string] $s)
Write-Output "###### $s"
}
function Check {
Param ([string] $s)
if ($LASTEXITCODE -ne 0) {
Log "Failed: $s"
throw "Error case -- see failed step"
}
}
$DockerOS = docker version -f "{{ .Server.Os }}"
write-host DockerOs:$DockerOS
$BaseBuildImageName = "github.com/ghstahl/hello-echo-container/hello-echo"
$Dockerfile = "hello-echo/Dockerfile"
PrintElapsedTime
Log "Build application image"
docker build --no-cache --pull -t $BaseBuildImageName -f $PSScriptRoot/$Dockerfile .
PrintElapsedTime
Check "docker build (application)"