-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
31 lines (29 loc) · 1.27 KB
/
build.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
[CmdletBinding()]
param(
[ValidateSet("coder","dotnet","jupyter")]
[Parameter(Mandatory)]
$path
)
Push-Location $PSScriptRoot -StackName PreBuild
if ($Path) {
Set-Location $Path
}
foreach ($DockerFile in Get-ChildItem -Recurse Dockerfile | Split-Path | Resolve-Path -relative) {
Push-Location $DockerFile
$Tag, $Name = ($DockerFile -split "[\\\/](?=[^\\\/]*$)", 2 ) -replace "[\\\/]", "-" -replace "^.-"
# $Tag, $Name = $DockerFile -replace "[\\\/]", "-" -replace "^.-" -split "-(?=[^-]*$)", 2
Write-Host "`n`n`nBuilding $DockerFile" -ForegroundColor Cyan
Write-Host "jaykul/$($Name):$($Tag)`n" -ForegroundColor Cyan
if(Get-Command gitversion) {
$version = gitversion | convertfrom-json
docker build -t "jaykul/$($Name):$($Tag)" -t "jaykul/$($Name):$($Tag)-$($version.SemVer)" -t "jaykul/$($Name):$($Tag)-$($version.Sha.Substring(0,9))" --label org.label-schema.vcs-ref=$($Version.SHA) --label org.label-schema.version=$($Version.SemVer) .
} else {
docker build -t "jaykul/$($Name):$($Tag)" .
}
Pop-Location
}
Pop-Location -StackName PreBuild
Write-Host "To upload these new images to docker hub, you'll want to run:
docker login
... and then push some images, like:
docker push jaykul/powershell"