forked from dotnet/dotnet-docker-nightly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-and-test.ps1
49 lines (41 loc) · 1.57 KB
/
build-and-test.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
[cmdletbinding()]
param(
[switch]$UseImageCache
)
Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'
if ($UseImageCache) {
$optionalDockerBuildArgs = ""
}
else {
$optionalDockerBuildArgs = "--no-cache"
}
$manifest = Get-Content "manifest.json" | ConvertFrom-Json
$manifestRepo = $manifest.Repos[0]
$platform = docker version -f "{{ .Server.Os }}"
$builtTags = @()
$manifestRepo.Images |
ForEach-Object {
$images = $_
$_.Platforms |
Where-Object {[bool]($_.PSobject.Properties.name -match $platform)} |
ForEach-Object {
$dockerfilePath = $_.$platform.dockerfile
$tags = $_.$platform.Tags
if ([bool]($images.PSobject.Properties.name -match "sharedTags")) {
$tags += $images.sharedTags
}
$qualifiedTags = $tags | ForEach-Object {
$manifestRepo.Name + ':' + $_.Replace('$(nanoServerVersion)', $manifest.TagVariables.NanoServerVersion)
}
$formattedTags = $qualifiedTags -join ', '
Write-Host "--- Building $formattedTags from $dockerfilePath ---"
Invoke-Expression "docker build $optionalDockerBuildArgs -t $($qualifiedTags -join ' -t ') $dockerfilePath"
if ($LastExitCode -ne 0) {
throw "Failed building $formattedTags"
}
$builtTags += $formattedTags
}
}
./test/run-test.ps1 -UseImageCache:$UseImageCache
Write-Host "Tags built and tested:`n$($builtTags | Out-String)"