From c4835880dac3f730e540d3a040241032e2885dd7 Mon Sep 17 00:00:00 2001 From: freddyk Date: Mon, 14 Dec 2020 11:40:54 +0100 Subject: [PATCH] update build scripts --- generic/Settings.ps1 | 2 +- generic/buildall.ps1 | 104 +++++++++++++++++++++++++--------------- generic/buildupdate.ps1 | 91 ++++------------------------------- 3 files changed, 76 insertions(+), 121 deletions(-) diff --git a/generic/Settings.ps1 b/generic/Settings.ps1 index 83135e7..e84b313 100644 --- a/generic/Settings.ps1 +++ b/generic/Settings.ps1 @@ -1,2 +1,2 @@ -$genericTag = "1.0.1.0" +$genericTag = "1.0.1.1" $created = [DateTime]::Now.ToUniversalTime().ToString("yyyyMMddHHmm") diff --git a/generic/buildall.ps1 b/generic/buildall.ps1 index 02a565c..f3829c1 100644 --- a/generic/buildall.ps1 +++ b/generic/buildall.ps1 @@ -2,13 +2,21 @@ . (Join-Path $RootPath "settings.ps1") +function Head($text) { + try { + $s = (New-Object System.Net.WebClient).DownloadString("http://artii.herokuapp.com/make?text=$text") + } catch { + $s = $text + } + Write-Host -ForegroundColor Yellow $s +} + $push = $true $supported = @( "10.0.19042.0" "10.0.19041.0" "10.0.18363.0" - "10.0.18362.0" "10.0.17763.0" "10.0.14393.0" ) @@ -18,30 +26,46 @@ $servercoretags = (get-navcontainerimagetags -imageName "mcr.microsoft.com/windo Sort-Object -Descending { [Version]$_ } | Group-Object { [Version]"$(([Version]$_).Major).$(([Version]$_).Minor).$(([Version]$_).Build).0" } | % { if ($supported.contains($_.Name)) { $_.Group[0] } } +Write-Host -ForegroundColor Yellow "Latest Servercore tags:" $servercoretags +$allbctags = (get-navcontainerimagetags -imageName "mcr.microsoft.com/businesscentral").tags | + Where-Object { [Version]::TryParse($_, [ref] $ver) } + +$bctags = $allbctags | Sort-Object -Descending { [Version]$_ } | + Group-Object { [Version]"$(([Version]$_).Major).$(([Version]$_).Minor).$(([Version]$_).Build).0" } | % { if ($supported.contains($_.Name)) { $_.Group[0] } } + +Write-Host -ForegroundColor Yellow "Latest BusinessCentral tags:" +$bctags + $basetags = (get-navcontainerimagetags -imageName "mcr.microsoft.com/dotnet/framework/runtime").tags | - Where-Object { $_.StartsWith('4.8-20') } | + Where-Object { $_ -like '4.8-20*' -and $_ -notlike '*-2009' -and $_ -notlike '*-1903'} | Sort-Object -Descending -$basetags +$basetags = @( +"4.8-windowsservercore-20H2" +"4.8-windowsservercore-2004" +"4.8-windowsservercore-1909" +"4.8-windowsservercore-ltsc2019" +"4.8-windowsservercore-ltsc2016" +) -#throw "go?" +#throw "start?" $start = 0 $start..($basetags.count-1) | % { $tag = $basetags[$_] - $dt = $tag.SubString(4,8) + $os = $tag.SubString($tag.LastIndexOf('-')+1) - Write-Host "$dt $os" + Head "$os" $baseimage = "mcr.microsoft.com/dotnet/framework/runtime:$tag" - $image = "$dt-generic:$os" + $image = "generic:$os" docker pull $baseimage $osversion = docker inspect --format "{{.OsVersion}}" $baseImage - + docker images --format "{{.Repository}}:{{.Tag}}" | % { if ($_ -eq $image) { @@ -49,38 +73,42 @@ $start..($basetags.count-1) | % { } } - $isolation = "hyperv" - - docker build --build-arg baseimage=$baseimage ` - --build-arg created=$created ` - --build-arg tag="$genericTag" ` - --build-arg osversion="$osversion" ` - --isolation=$isolation ` - --memory 10G ` - --tag $image ` - $RootPath - - if ($LASTEXITCODE -ne 0) { - throw "Failed with exit code $LastExitCode" - } - Write-Host "SUCCESS" + if ($allbctags -notcontains $osversion) { - if ($push) { - $tags = @( - "mcrbusinesscentral.azurecr.io/public/businesscentral:$osversion" - "mcrbusinesscentral.azurecr.io/public/businesscentral:$osversion-$genericTag" - "mcrbusinesscentral.azurecr.io/public/businesscentral:$osversion-dev" - ) - $tags | ForEach-Object { - Write-Host "Push $_" - docker tag $image $_ - docker push $_ + head $osversion + + $isolation = "hyperv" + + docker build --build-arg baseimage=$baseimage ` + --build-arg created=$created ` + --build-arg tag="$genericTag" ` + --build-arg osversion="$osversion" ` + --isolation=$isolation ` + --memory 10G ` + --tag $image ` + $RootPath + + if ($LASTEXITCODE -ne 0) { + throw "Failed with exit code $LastExitCode" } - $tags | ForEach-Object { - Write-Host "Remove $_" - docker rmi $_ + Write-Host "SUCCESS" + + if ($push) { + $tags = @( + "mcrbusinesscentral.azurecr.io/public/businesscentral:$osversion" + "mcrbusinesscentral.azurecr.io/public/businesscentral:$osversion-$genericTag" + "mcrbusinesscentral.azurecr.io/public/businesscentral:$osversion-dev" + ) + $tags | ForEach-Object { + Write-Host "Push $_" + docker tag $image $_ + docker push $_ + } + $tags | ForEach-Object { + Write-Host "Remove $_" + docker rmi $_ + } + docker rmi $image } - docker rmi $image - docker rmi $baseimage } } diff --git a/generic/buildupdate.ps1 b/generic/buildupdate.ps1 index edc33f1..deac9d4 100644 --- a/generic/buildupdate.ps1 +++ b/generic/buildupdate.ps1 @@ -16,95 +16,19 @@ $testImages = $false $pushto = @() $pushto = @("dev") -#$pushto = @("prod") -#$pushto = @("dev","prod") +#$pushto += @("prod") -$tags = @( -"10.0.14393.2906-1.0.0.0" -"10.0.14393.2972-1.0.0.0" -"10.0.14393.3025-1.0.0.0" -"10.0.14393.3085-1.0.0.0" -"10.0.14393.3144-1.0.0.0" -"10.0.14393.3204-1.0.0.0" -"10.0.14393.3326-1.0.0.0" -"10.0.14393.3384-1.0.0.0" -"10.0.14393.3443-1.0.0.0" -"10.0.14393.3630-1.0.0.0" -"10.0.14393.3750-1.0.0.0" -"10.0.14393.3808-1.0.0.0" -"10.0.14393.3866-1.0.0.0" -"10.0.14393.3930-1.0.0.0" -"10.0.14393.3986-1.0.0.0" -"10.0.14393.4046-1.0.0.0" -"10.0.17134.1006-1.0.0.0" -"10.0.17134.1130-1.0.0.0" -"10.0.17134.706-1.0.0.0" -"10.0.17134.766-1.0.0.0" -"10.0.17134.829-1.0.0.0" -"10.0.17134.885-1.0.0.0" -"10.0.17134.950-1.0.0.0" -"10.0.17763.1158-1.0.0.0" -"10.0.17763.1282-1.0.0.0" -"10.0.17763.1339-1.0.0.0" -"10.0.17763.1397-1.0.0.0" -"10.0.17763.1457-1.0.0.0" -"10.0.17763.1518-1.0.0.0" -"10.0.17763.1577-1.0.0.0" -"10.0.17763.437-1.0.0.0" -"10.0.17763.504-1.0.0.0" -"10.0.17763.557-1.0.0.0" -"10.0.17763.615-1.0.0.0" -"10.0.17763.678-1.0.0.0" -"10.0.17763.737-1.0.0.0" -"10.0.17763.864-1.0.0.0" -"10.0.17763.914-1.0.0.0" -"10.0.17763.973-1.0.0.0" -"10.0.18362.1016-1.0.0.0" -"10.0.18362.1082-1.0.0.0" -"10.0.18362.1139-1.0.0.0" -"10.0.18362.116-1.0.0.0" -"10.0.18362.1198-1.0.0.0" -"10.0.18362.175-1.0.0.0" -"10.0.18362.239-1.0.0.0" -"10.0.18362.295-1.0.0.0" -"10.0.18362.356-1.0.0.0" -"10.0.18362.476-1.0.0.0" -"10.0.18362.535-1.0.0.0" -"10.0.18362.592-1.0.0.0" -"10.0.18362.658-1.0.0.0" -"10.0.18362.778-1.0.0.0" -"10.0.18362.900-1.0.0.0" -"10.0.18362.959-1.0.0.0" -"10.0.18363.1016-1.0.0.0" -"10.0.18363.1082-1.0.0.0" -"10.0.18363.1139-1.0.0.0" -"10.0.18363.1198-1.0.0.0" -"10.0.18363.476-1.0.0.0" -"10.0.18363.535-1.0.0.0" -"10.0.18363.592-1.0.0.0" -"10.0.18363.658-1.0.0.0" -"10.0.18363.778-1.0.0.0" -"10.0.18363.900-1.0.0.0" -"10.0.18363.959-1.0.0.0" -"10.0.19041.329-1.0.0.0" -"10.0.19041.388-1.0.0.0" -"10.0.19041.450-1.0.0.0" -"10.0.19041.508-1.0.0.0" -"10.0.19041.572-1.0.0.0" -"10.0.19041.630-1.0.0.0" -"10.0.19042.572-1.0.0.0" -"10.0.19042.630-1.0.0.0" - -) +$ver = [Version]"10.0.0.0" +$tags = (get-navcontainerimagetags -imageName "mcr.microsoft.com/businesscentral").tags | + Where-Object { [Version]::TryParse($_, [ref] $ver) } [Array]::Reverse($tags) -$oldGenericTag = "1.0.0.1" +$oldGenericTag = "1.0.1.0" $tags | % { $tag = $_ - $osversion = $tag.Substring(0,$tag.IndexOf('-')) - $image = "my:$osversion-$oldGenericTag" + $image = "my:$tag-$oldGenericTag" docker images --format "{{.Repository}}:{{.Tag}}" | % { if ($_ -eq $image) @@ -114,6 +38,7 @@ $tags | % { } } +# Pull all $tags | % { $tag = $_ head $tag @@ -121,6 +46,8 @@ $tags | % { docker pull $image } +docker system prune --force + throw "go!" $tags | % {