-
Notifications
You must be signed in to change notification settings - Fork 121
/
Copy pathdocker-publish.ps1
executable file
·70 lines (52 loc) · 1.86 KB
/
docker-publish.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Helper script to execute docker buildx
.DESCRIPTION
Simplifies executing docker buildx for multi-architecture for the current Dockerfile
.PARAMETER Version
Specifies the version number to take this image with (defaults to 'latest' only)
.PARAMETER DockerAccount
The docker account to use to push the image
.PARAMETER Platforms
The platforms to target for the image (defaults to linux/arm64/v8,linux/amd64)
.INPUTS
None. You cannot pipe objects to to this script.
.OUTPUTS
None
.EXAMPLE
PS> /docker-publish.ps1
.EXAMPLE
PS> ./docker-publish.ps1 -Version v1.7.4
.EXAMPLE
PS> ./docker-publish.ps1 -Platforms "linux/arms64/v8"
#>
param(
[string]$Version = "",
[string]$DockerAccount = "rogerfar",
[string]$Platforms = "linux/arm64/v8,linux/amd64",
[string]$Dockerfile = "Dockerfile",
[switch]$SkipPush,
[switch]$SkipCache,
[switch]$OutputToDocker,
[string]$BuildProgress="auto"
)
$imageName = "$($DockerAccount)/rdtclient"
$dockerArgs = @( "buildx", "build", "--network=default", "--platform", $Platforms, "--progress=$BuildProgress", "--tag", "$($imageName):latest", "--file", $Dockerfile, "." )
if (-Not $SkipPush.IsPresent) {
$dockerArgs += @("--push")
}
if ($SkipCache.IsPresent) {
$dockerArgs += @("--no-cache")
}
if ($OutputToDocker.IsPresent) {
$dockerArgs += @("--load")
}
if ([string]::IsNullOrEmpty($Version)) {
$Version = (Get-Content "package.json" | ConvertFrom-Json).version
}
$dockerArgs += @("--tag", "$($imageName):$($Version)" )
$dockerApps += @("--build-arg", "VERSION=$($Version)" )
Write-Host "Generating docker image $imageName for $Platforms"
Write-Host "Args: $dockerArgs"
& docker $dockerArgs