Fix vulnerabilities and BC 24 issues (#547)
Co-authored-by: freddydk <freddydk@users.noreply.github.com>
This commit is contained in:
Родитель
98c0702dbd
Коммит
fdbb3372ad
|
@ -7,20 +7,9 @@ on:
|
||||||
description: Generic Tag (leave empty to use value in generic/tag.txt)
|
description: Generic Tag (leave empty to use value in generic/tag.txt)
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
Agents:
|
|
||||||
description: Number of agents to create (0 = use existing)
|
|
||||||
required: false
|
|
||||||
default: '2'
|
|
||||||
PushToProd:
|
PushToProd:
|
||||||
description: Push to production (Y/N)
|
description: Push to production (Y/N)
|
||||||
required: false
|
type: boolean
|
||||||
default: 'Y'
|
|
||||||
|
|
||||||
env:
|
|
||||||
resGroup: "buildgeneric"
|
|
||||||
resLocation: "Sweden Central"
|
|
||||||
ARMbranch: "master"
|
|
||||||
ARMtemplate: "buildagent"
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
@ -33,179 +22,72 @@ jobs:
|
||||||
AnalyzeImages:
|
AnalyzeImages:
|
||||||
runs-on: [ windows-latest ]
|
runs-on: [ windows-latest ]
|
||||||
outputs:
|
outputs:
|
||||||
generic: ${{ steps.Analyze.outputs.generic }}
|
missing: ${{ steps.Analyze.outputs.missing }}
|
||||||
genericcount: ${{ steps.Analyze.outputs.genericcount }}
|
missingcount: ${{ steps.Analyze.outputs.missingcount }}
|
||||||
filesonly: ${{ steps.Analyze.outputs.filesonly }}
|
|
||||||
filesonlycount: ${{ steps.Analyze.outputs.filesonlycount }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Analyze
|
- name: Analyze
|
||||||
id: Analyze
|
id: Analyze
|
||||||
|
env:
|
||||||
|
genericTag: ${{ github.event.inputs.GenericTag }}
|
||||||
run: |
|
run: |
|
||||||
$erroractionpreference = "STOP"
|
$erroractionpreference = "STOP"
|
||||||
try {
|
try {
|
||||||
$unsupportedWindowsVersions = @("10.0.14300.*","10.0.16299.*","10.0.18363.*","10.0.18362.*","10.0.17134.*") # "10.0.14393.*","10.0.19041.*","10.0.19042.*"
|
$servercoretags = @('ltsc2016','ltsc2019','ltsc2022')
|
||||||
Set-Location "generic"
|
Set-Location "generic"
|
||||||
$genericTag = ''
|
$genericTag = "$env:genericTag"
|
||||||
if ($env:GITHUB_EVENT_NAME -eq "workflow_dispatch") {
|
|
||||||
$genericTag = '${{ github.event.inputs.GenericTag }}'
|
|
||||||
}
|
|
||||||
if ($genericTag -eq '') { $genericTag = Get-Content -path 'tag.txt' }
|
if ($genericTag -eq '') { $genericTag = Get-Content -path 'tag.txt' }
|
||||||
[System.Version]$genericTag | Out-Null
|
[System.Version]$genericTag | Out-Null
|
||||||
Write-Host "Using generic Tag $genericTag"
|
Write-Host "Using generic Tag $genericTag"
|
||||||
$genericTag = "-$genericTag"
|
|
||||||
$webclient = New-Object System.Net.WebClient
|
$webclient = New-Object System.Net.WebClient
|
||||||
$webclient.Headers.Add('Accept', "application/json")
|
$webclient.Headers.Add('Accept', "application/json")
|
||||||
|
$neededBcTags = $serverCoreTags | ForEach-Object {
|
||||||
|
$osVersion = [System.Version](($webclient.DownloadString("https://mcr.microsoft.com/v2/dotnet/framework/runtime/manifests/4.8-windowsservercore-$_") | ConvertFrom-Json).history[0].v1Compatibility | ConvertFrom-Json)."os.version"
|
||||||
|
"$osVersion-$genericTag|mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-$_|$_"
|
||||||
|
"$osVersion-$genericTag-24|mcr.microsoft.com/windows/servercore:$_|$_"
|
||||||
|
"$osVersion-$genericTag-filesonly|mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-$_|$_"
|
||||||
|
"$osVersion-$genericTag-24-filesonly|mcr.microsoft.com/windows/servercore:$_|$_"
|
||||||
|
}
|
||||||
|
Write-Host "Needed Tags ($($neededBcTags.Count))"
|
||||||
|
$neededBcTags | ForEach-Object { Write-Host "- $_" }
|
||||||
$alltags = (($webclient.DownloadString("https://mcr.microsoft.com/v2/businesscentral/tags/list") | ConvertFrom-Json)).tags
|
$alltags = (($webclient.DownloadString("https://mcr.microsoft.com/v2/businesscentral/tags/list") | ConvertFrom-Json)).tags
|
||||||
$version = [System.Version]"0.0.0.0"
|
$missingBcTags = @($neededBcTags | Where-Object { $alltags -notcontains $_ })
|
||||||
$versions = @($alltags | Where-Object { $_ -like "*$generictag" } | Where-Object { [System.Version]::TryParse($_.SubString(0,$_.Length-$generictag.Length), [ref] $version) } | Where-Object { -not ($UnsupportedWindowsVersions | Where-Object { "$version" -like $_ }) } | ForEach-Object { $version })
|
Write-Host "Missing Tags ($($missingBcTags.Count))"
|
||||||
$filesOnlyVersions = @($alltags | Where-Object { $_ -like "*$generictag-filesonly" } | Where-Object { [System.Version]::TryParse($_.SubString(0,$_.Length-$generictag.Length-10), [ref] $version) } | Where-Object { -not ($UnsupportedWindowsVersions | Where-Object { "$version" -like $_ }) } | ForEach-Object { $version })
|
if ($missingBcTags) {
|
||||||
$missingImages = @{}
|
$missingBcTags | ForEach-Object { Write-Host "- $_" }
|
||||||
$missingFilesOnlyImages = @{}
|
|
||||||
$alldotnetFrameworkTags = (($webclient.DownloadString("https://mcr.microsoft.com/v2/dotnet/framework/runtime/tags/list") | ConvertFrom-Json)).tags
|
|
||||||
$alldotnetFrameworkTags | Where-Object { $_.startswith("4.8-w") -or $_.startswith("4.8-20") } | ForEach-Object {
|
|
||||||
$osVersion = [System.Version](($webclient.DownloadString("https://mcr.microsoft.com/v2/dotnet/framework/runtime/manifests/$_") | ConvertFrom-Json).history[0].v1Compatibility | ConvertFrom-Json)."os.version"
|
|
||||||
if (-not ($UnsupportedWindowsVersions | Where-Object { "$osVersion" -like $_ })) {
|
|
||||||
Write-Host -NoNewline "Test $_ ($OSVersion)"
|
|
||||||
if ($versions.Contains($osversion)) {
|
|
||||||
Write-Host -NoNewline " - OK"
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$missingImages."$osversion" = $_
|
Write-Host '- none'
|
||||||
Write-Host -NoNewline " - Missing"
|
|
||||||
}
|
}
|
||||||
if ($filesOnlyVersions.Contains($osversion)) {
|
$json = ConvertTo-Json -InputObject $missingBcTags -Compress
|
||||||
Write-Host " - OK"
|
$json | Out-Host
|
||||||
}
|
Add-Content -encoding utf8 -Path $ENV:GITHUB_OUTPUT -Value "missing=$json"
|
||||||
else {
|
Write-Host "missing=$json"
|
||||||
$missingFilesOnlyImages."$osversion" = $_
|
Add-Content -encoding utf8 -Path $ENV:GITHUB_OUTPUT -Value "missingcount=$($missingBcTags.Count)"
|
||||||
Write-Host " - Missing"
|
Write-Host "missingcount=$($missingBcTags.Count)"
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$genericarray = @($missingImages.GetEnumerator() | Where-Object { $_ } | ForEach-Object { "$($_.name)|$($_.value)" })
|
|
||||||
$genericcount = $genericarray.Count
|
|
||||||
$generic = $genericarray | ConvertTo-Json -Compress
|
|
||||||
Add-Content -Path $ENV:GITHUB_OUTPUT -Value "generic=[$("$generic".Trim('[]'))]"
|
|
||||||
Write-Host "generic=[$("$generic".Trim('[]'))]"
|
|
||||||
Add-Content -Path $ENV:GITHUB_OUTPUT -Value "genericcount=$genericcount"
|
|
||||||
Write-Host "genericcount=$genericcount"
|
|
||||||
$filesonlyarray = @($missingFilesOnlyImages.GetEnumerator() | Where-Object { $_ } | ForEach-Object { "$($_.name)-filesonly|$($_.value)" })
|
|
||||||
$filesonlycount = $filesonlyarray.Count
|
|
||||||
$filesonly = $filesonlyarray | ConvertTo-Json -Compress
|
|
||||||
Add-Content -Path $ENV:GITHUB_OUTPUT -Value "filesonly=[$("$filesonly".Trim('[]'))]"
|
|
||||||
Write-Host "filesonly=[$("$filesonly".Trim('[]'))]"
|
|
||||||
Add-Content -Path $ENV:GITHUB_OUTPUT -Value "filesonlycount=$filesonlycount"
|
|
||||||
Write-Host "filesonlycount=$filesonlycount"
|
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host "::Error::Error analyzing images. Error was $($_.Exception.Message)"
|
Write-Host "::Error::Error analyzing images. Error was $($_.Exception.Message)"
|
||||||
$host.SetShouldExit(1)
|
$host.SetShouldExit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateAgents:
|
Missing:
|
||||||
runs-on: [ windows-latest ]
|
runs-on: [ Windows-Latest ]
|
||||||
needs: [ AnalyzeImages ]
|
needs: [ AnalyzeImages ]
|
||||||
if: ${{ needs.AnalyzeImages.outputs.genericcount > 0 || needs.AnalyzeImages.outputs.filesonlycount > 0 }}
|
if: ${{ needs.AnalyzeImages.outputs.missingcount > 0 }}
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: azure/login@v1
|
|
||||||
with:
|
|
||||||
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
|
||||||
enable-AzPSSession: true
|
|
||||||
|
|
||||||
- name: Run Azure PowerShell script
|
|
||||||
uses: azure/powershell@v1
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
||||||
agents: ${{ github.event.inputs.Agents }}
|
|
||||||
with:
|
|
||||||
azPSVersion: "latest"
|
|
||||||
inlineScript: |
|
|
||||||
if ($env:agents -eq "0") {
|
|
||||||
Write-Host "Using existing agents"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$resGroup = $env:resGroup
|
|
||||||
$resLocation = $env:resLocation
|
|
||||||
$repo = $env:GITHUB_REPOSITORY
|
|
||||||
$agents = [int]$env:agents
|
|
||||||
Write-Host "Resource Group is $resGroup"
|
|
||||||
$resourceGroup = Get-AzResourceGroup -name $resGroup -ErrorAction Ignore
|
|
||||||
if ($resourceGroup) {
|
|
||||||
Write-Host "Removing Resource Group $resGroup"
|
|
||||||
Remove-AzResourceGroup -Name $resGroup -Force | Out-Host
|
|
||||||
Write-Host "Done"
|
|
||||||
}
|
|
||||||
$runners = (gh api /repos/$repo/actions/runners | ConvertFrom-Json).runners
|
|
||||||
$runners | Where-Object { $_.status -eq "offline" } | ForEach-Object {
|
|
||||||
Write-host "Unregistering runner $($_.name)"
|
|
||||||
$id = $_.id
|
|
||||||
gh api -X DELETE /repos/$repo/actions/runners/$id
|
|
||||||
Write-Host "Done"
|
|
||||||
}
|
|
||||||
Write-Host "Creating resource group $resGroup in $resLocation"
|
|
||||||
$resourceGroup = New-AzResourceGroup -Name $resGroup -Location $resLocation -Force
|
|
||||||
Write-Host "Done"
|
|
||||||
1..$agents | ForEach-Object {
|
|
||||||
# Deployment
|
|
||||||
$no = $_
|
|
||||||
# ARM template
|
|
||||||
$templateUri = "https://raw.githubusercontent.com/microsoft/nav-arm-templates/$($env:ARMbranch)/$($env:ARMtemplate).json"
|
|
||||||
$registrationToken = (gh api -X POST /repos/$repo/actions/runners/registration-token | ConvertFrom-Json).token
|
|
||||||
$headers = @{
|
|
||||||
"Accept" = "application/json"
|
|
||||||
"Authorization" = "token $env:GH_TOKEN"
|
|
||||||
}
|
|
||||||
$uri = "https://api.github.com/repos/actions/runner/releases"
|
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
|
|
||||||
$result = Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri $uri
|
|
||||||
$releases = $result.Content | ConvertFrom-Json
|
|
||||||
$asset = $releases[0].assets | Where-Object { $_.name -like "actions-runner-win-x64-*.*.?.zip" }
|
|
||||||
$Parameters = @{
|
|
||||||
"VmName" = "$resgroup$no"
|
|
||||||
"Remotedesktopaccess" = "-"
|
|
||||||
"OperatingSystem" = "Windows Server 2022"
|
|
||||||
"VmSize" = "Standard_D4as_v5"
|
|
||||||
"OSDiskSize" = 128
|
|
||||||
"StorageAccountType" = "Premium_LRS"
|
|
||||||
"AdminPassword" = [SecureString](ConvertTo-SecureString -String $env:GH_TOKEN -AsPlainText -Force)
|
|
||||||
"Count" = 1
|
|
||||||
"Token" = $registrationToken
|
|
||||||
"Organization" = "https://github.com/$repo"
|
|
||||||
"LabelsOrPool" = "buildgeneric"
|
|
||||||
"AgentUrl" = $asset.browser_download_url
|
|
||||||
"InstallHyperV" = "Yes"
|
|
||||||
"RunInsideDocker" = "No"
|
|
||||||
"FinalSetupScriptUrl" = "additional-installforbuildagent.ps1"
|
|
||||||
}
|
|
||||||
$err = $resourceGroup | Test-AzResourceGroupDeployment -TemplateUri $templateUri -TemplateParameterObject $Parameters
|
|
||||||
if ($err) {
|
|
||||||
$err
|
|
||||||
throw "stop"
|
|
||||||
}
|
|
||||||
Write-Host "Creating Azure VM $($parameters.VmName)"
|
|
||||||
$resourceGroup | New-AzResourceGroupDeployment -TemplateUri $templateUri -TemplateParameterObject $Parameters -Name $Parameters.vmName -ErrorAction Ignore -AsJob
|
|
||||||
Start-Sleep -Seconds 60
|
|
||||||
Write-Host "VM creation started"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Generic:
|
|
||||||
runs-on: [ buildgeneric ]
|
|
||||||
needs: [ AnalyzeImages, CreateAgents ]
|
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
version: ${{fromJson(needs.AnalyzeImages.outputs.generic)}}
|
tag: ${{fromJson(needs.AnalyzeImages.outputs.missing)}}
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
max-parallel: 5
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Build Image
|
- name: Build Image
|
||||||
|
env:
|
||||||
|
PushToProd: ${{ github.event.inputs.PushToProd }}
|
||||||
|
GenericTag: ${{ github.event.inputs.GenericTag }}
|
||||||
run: |
|
run: |
|
||||||
$erroractionpreference = "STOP"
|
$erroractionpreference = "STOP"
|
||||||
Set-StrictMode -version 2.0
|
Set-StrictMode -version 2.0
|
||||||
|
@ -223,32 +105,50 @@ jobs:
|
||||||
$genericTag = ''
|
$genericTag = ''
|
||||||
$pushToProd = $true
|
$pushToProd = $true
|
||||||
if ($env:GITHUB_EVENT_NAME -eq "workflow_dispatch") {
|
if ($env:GITHUB_EVENT_NAME -eq "workflow_dispatch") {
|
||||||
$genericTag = '${{ github.event.inputs.GenericTag }}'
|
$genericTag = $env:GenericTag
|
||||||
$pushToProd = '${{ github.event.inputs.PushToProd }}' -eq 'Y'
|
$pushToProd = $env:PushToProd -eq 'True'
|
||||||
}
|
}
|
||||||
if ($genericTag -eq '') { $genericTag = Get-Content -path 'tag.txt' }
|
if ($genericTag -eq '') { $genericTag = Get-Content -path 'tag.txt' }
|
||||||
[System.Version]$genericTag | Out-Null
|
[System.Version]$genericTag | Out-Null
|
||||||
$osversion = '${{ matrix.version }}'.split('|')[0].split('-')[0]
|
$osversion = '${{ matrix.tag }}'.split('|')[0].split('-')[0]
|
||||||
$filesonly = ''
|
$filesonly = ('${{ matrix.tag }}' -like '*-filesonly|*')
|
||||||
if ('${{ matrix.version }}' -like '*-filesonly|*') {
|
$only24 = ('${{ matrix.tag }}' -like '*-24|*' -or '${{ matrix.tag }}' -like '*-24-filesonly|*')
|
||||||
$filesonly = '-filesonly'
|
$baseImage = '${{ matrix.tag }}'.split('|')[1]
|
||||||
}
|
$ltscTag = '${{ matrix.tag }}'.split('|')[2]
|
||||||
$dotnetFrameworkTag = '${{ matrix.version }}'.split('|')[1]
|
|
||||||
$baseimage = "mcr.microsoft.com/dotnet/framework/runtime:$dotnetFrameworkTag"
|
|
||||||
|
|
||||||
$rootPath = Get-Location
|
$rootPath = Get-Location
|
||||||
$dockerfile = Join-Path $rootPath "DOCKERFILE$filesonly"
|
$dockerfile = Join-Path $rootPath "DOCKERFILE"
|
||||||
|
$strFilesOnly = ''
|
||||||
$image = "my:$osversion-$genericTag$filesonly"
|
$str24 = ''
|
||||||
|
if ($only24) {
|
||||||
|
$str24 = "-24"
|
||||||
|
}
|
||||||
|
if ($filesOnly) {
|
||||||
|
$strFilesOnly = "-filesonly"
|
||||||
|
$dockerfile += '-filesonly'
|
||||||
|
}
|
||||||
|
$image = "my:$osversion-$genericTag$str24$strFilesOnly"
|
||||||
|
$newtags = @(
|
||||||
|
"$pushRegistry/public/businesscentral:$osversion$str24$strFilesonly-dev"
|
||||||
|
"$pushRegistry/public/businesscentral:$ltscTag$str24$strFilesonly-dev"
|
||||||
|
)
|
||||||
|
if ($pushToProd) {
|
||||||
|
$newtags += @(
|
||||||
|
"$pushRegistry/public/businesscentral:$osversion$str24$strFilesonly"
|
||||||
|
"$pushRegistry/public/businesscentral:$osversion-$genericTag$str24$strFilesonly"
|
||||||
|
"$pushRegistry/public/businesscentral:$ltscTag$str24$strFilesonly"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
$newTags | out-host
|
||||||
$created = [DateTime]::Now.ToUniversalTime().ToString("yyyyMMddHHmm")
|
$created = [DateTime]::Now.ToUniversalTime().ToString("yyyyMMddHHmm")
|
||||||
docker pull $baseimage
|
docker pull $baseimage
|
||||||
$inspect = docker inspect $baseimage | ConvertFrom-Json
|
$inspect = docker inspect $baseimage | ConvertFrom-Json
|
||||||
|
|
||||||
$success = $false
|
$success = $false
|
||||||
docker build --build-arg baseimage=$baseimage `
|
docker build --build-arg baseimage=$baseimage `
|
||||||
--build-arg created=$created `
|
--build-arg created=$created `
|
||||||
--build-arg tag="$genericTag" `
|
--build-arg tag="$genericTag" `
|
||||||
--build-arg osversion="$osversion" `
|
--build-arg osversion="$osversion" `
|
||||||
|
--build-arg filesonly="$filesonly" `
|
||||||
|
--build-arg only24="$only24" `
|
||||||
--isolation=hyperv `
|
--isolation=hyperv `
|
||||||
--memory 8G `
|
--memory 8G `
|
||||||
--tag $image `
|
--tag $image `
|
||||||
|
@ -262,165 +162,13 @@ jobs:
|
||||||
if (!$success) {
|
if (!$success) {
|
||||||
throw "Error building image"
|
throw "Error building image"
|
||||||
}
|
}
|
||||||
$newtags = @(
|
|
||||||
"$pushRegistry/public/businesscentral:$osversion$filesonly-dev"
|
|
||||||
)
|
|
||||||
if ($pushToProd) {
|
|
||||||
$newtags += @(
|
|
||||||
"$pushRegistry/public/businesscentral:$osversion$filesonly"
|
|
||||||
"$pushRegistry/public/businesscentral:$osversion-$genericTag$filesonly"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
$newtags | ForEach-Object {
|
$newtags | ForEach-Object {
|
||||||
Write-Host "Push $_"
|
Write-Host "Push $_"
|
||||||
docker tag $image $_
|
docker tag $image $_
|
||||||
docker push $_
|
docker push $_
|
||||||
}
|
}
|
||||||
$newtags | ForEach-Object {
|
|
||||||
docker rmi $_
|
|
||||||
}
|
|
||||||
docker rmi $image
|
|
||||||
docker rmi $baseimage
|
|
||||||
docker system prune --force
|
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host "::Error::Error building images. Error was $($_.Exception.Message)"
|
Write-Host "::Error::Error building images. Error was $($_.Exception.Message)"
|
||||||
$host.SetShouldExit(1)
|
$host.SetShouldExit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
FilesOnly:
|
|
||||||
runs-on: [ buildgeneric ]
|
|
||||||
needs: [ AnalyzeImages, CreateAgents ]
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
version: ${{fromJson(needs.AnalyzeImages.outputs.filesonly)}}
|
|
||||||
fail-fast: false
|
|
||||||
max-parallel: 5
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Build Image
|
|
||||||
run: |
|
|
||||||
$erroractionpreference = "STOP"
|
|
||||||
Set-StrictMode -version 2.0
|
|
||||||
try {
|
|
||||||
$pushRegistry = "mcrbusinesscentral.azurecr.io"
|
|
||||||
$job = start-job -ScriptBlock { Param($username, $token, $registry)
|
|
||||||
Write-Output $token | docker login --username $username --password-stdin $registry
|
|
||||||
} -ArgumentList '${{ secrets.PushUsername }}', '${{ secrets.PushToken }}', $pushRegistry
|
|
||||||
$job | Wait-Job -ErrorAction SilentlyContinue -WarningAction SilentlyContinue | Out-Null
|
|
||||||
$result = Receive-Job -ErrorAction SilentlyContinue -WarningAction SilentlyContinue $job 2> $NULL
|
|
||||||
if ($result -ne 'Login Succeeded') {
|
|
||||||
throw "docker login failed"
|
|
||||||
}
|
|
||||||
Set-Location "generic"
|
|
||||||
$genericTag = ''
|
|
||||||
$pushToProd = $true
|
|
||||||
if ($env:GITHUB_EVENT_NAME -eq "workflow_dispatch") {
|
|
||||||
$genericTag = '${{ github.event.inputs.GenericTag }}'
|
|
||||||
$pushToProd = '${{ github.event.inputs.PushToProd }}' -eq 'Y'
|
|
||||||
}
|
|
||||||
if ($genericTag -eq '') { $genericTag = Get-Content -path 'tag.txt' }
|
|
||||||
[System.Version]$genericTag | Out-Null
|
|
||||||
$osversion = '${{ matrix.version }}'.split('|')[0].split('-')[0]
|
|
||||||
$filesonly = ''
|
|
||||||
if ('${{ matrix.version }}' -like '*-filesonly|*') {
|
|
||||||
$filesonly = '-filesonly'
|
|
||||||
}
|
|
||||||
$dotnetFrameworkTag = '${{ matrix.version }}'.split('|')[1]
|
|
||||||
$baseimage = "mcr.microsoft.com/dotnet/framework/runtime:$dotnetFrameworkTag"
|
|
||||||
|
|
||||||
$rootPath = Get-Location
|
|
||||||
$dockerfile = Join-Path $rootPath "DOCKERFILE$filesonly"
|
|
||||||
|
|
||||||
$image = "my:$osversion-$genericTag$filesonly"
|
|
||||||
$created = [DateTime]::Now.ToUniversalTime().ToString("yyyyMMddHHmm")
|
|
||||||
docker pull $baseimage
|
|
||||||
$inspect = docker inspect $baseimage | ConvertFrom-Json
|
|
||||||
|
|
||||||
$success = $false
|
|
||||||
docker build --build-arg baseimage=$baseimage `
|
|
||||||
--build-arg created=$created `
|
|
||||||
--build-arg tag="$genericTag" `
|
|
||||||
--build-arg osversion="$osversion" `
|
|
||||||
--isolation=hyperv `
|
|
||||||
--memory 8G `
|
|
||||||
--tag $image `
|
|
||||||
--file $dockerfile `
|
|
||||||
$RootPath | % {
|
|
||||||
$_ | Out-Host
|
|
||||||
if ($_ -like "Successfully built*") {
|
|
||||||
$success = $true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!$success) {
|
|
||||||
throw "Error building image"
|
|
||||||
}
|
|
||||||
$newtags = @(
|
|
||||||
"$pushRegistry/public/businesscentral:$osversion$filesonly-dev"
|
|
||||||
)
|
|
||||||
if ($pushToProd) {
|
|
||||||
$newtags += @(
|
|
||||||
"$pushRegistry/public/businesscentral:$osversion$filesonly"
|
|
||||||
"$pushRegistry/public/businesscentral:$osversion-$genericTag$filesonly"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
$newtags | ForEach-Object {
|
|
||||||
Write-Host "Push $_"
|
|
||||||
docker tag $image $_
|
|
||||||
docker push $_
|
|
||||||
}
|
|
||||||
$newtags | ForEach-Object {
|
|
||||||
docker rmi $_
|
|
||||||
}
|
|
||||||
docker rmi $image
|
|
||||||
docker rmi $baseimage
|
|
||||||
docker system prune --force
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
Write-Host "::Error::Error building images. Error was $($_.Exception.Message)"
|
|
||||||
$host.SetShouldExit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
RemoveAgents:
|
|
||||||
runs-on: [ windows-latest ]
|
|
||||||
needs: [ AnalyzeImages, CreateAgents, Generic, FilesOnly ]
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: azure/login@v1
|
|
||||||
with:
|
|
||||||
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
|
||||||
enable-AzPSSession: true
|
|
||||||
|
|
||||||
- name: Run Azure PowerShell script
|
|
||||||
uses: azure/powershell@v1
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
||||||
agents: ${{ github.event.inputs.Agents }}
|
|
||||||
with:
|
|
||||||
azPSVersion: "latest"
|
|
||||||
inlineScript: |
|
|
||||||
if ($env:agents -eq "0") {
|
|
||||||
Write-Host "Used existing agents"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$resGroup = $env:resGroup
|
|
||||||
$resLocation = $env:resLocation
|
|
||||||
$repo = $env:GITHUB_REPOSITORY
|
|
||||||
Write-Host "Resource Group is $resGroup"
|
|
||||||
$resourceGroup = Get-AzResourceGroup -name $resGroup -ErrorAction Ignore
|
|
||||||
if ($resourceGroup) {
|
|
||||||
Write-Host "Removing Resource Group $resGroup"
|
|
||||||
Remove-AzResourceGroup -Name $resGroup -Force | Out-Host
|
|
||||||
Write-Host "Done"
|
|
||||||
}
|
|
||||||
$runners = (gh api /repos/$repo/actions/runners | ConvertFrom-Json).runners
|
|
||||||
$runners | Where-Object { $_.status -eq "offline" } | ForEach-Object {
|
|
||||||
Write-host "Unregistering runner $($_.name)"
|
|
||||||
$id = $_.id
|
|
||||||
gh api -X DELETE /repos/$repo/actions/runners/$id
|
|
||||||
Write-Host "Done"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,142 +0,0 @@
|
||||||
name: Create Self-Hosted Agents
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
Count:
|
|
||||||
description: Number of agents to create?
|
|
||||||
required: true
|
|
||||||
default: 2
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: PowerShell
|
|
||||||
|
|
||||||
env:
|
|
||||||
resGroup: "buildgeneric"
|
|
||||||
resLocation: "West Europe"
|
|
||||||
machines: "5"
|
|
||||||
ARMbranch: "master"
|
|
||||||
ARMtemplate: "buildagent"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
Preparation:
|
|
||||||
runs-on: [ windows-latest ]
|
|
||||||
outputs:
|
|
||||||
matrix: ${{steps.CalculateMatrix.outputs.matrix}}
|
|
||||||
steps:
|
|
||||||
- name: Azure Login
|
|
||||||
uses: azure/login@v1
|
|
||||||
with:
|
|
||||||
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
|
||||||
enable-AzPSSession: true
|
|
||||||
|
|
||||||
- name: Remove Old Agents
|
|
||||||
uses: azure/powershell@v1
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
||||||
with:
|
|
||||||
azPSVersion: "latest"
|
|
||||||
inlineScript: |
|
|
||||||
$resGroup = $env:resGroup
|
|
||||||
$repo = $env:GITHUB_REPOSITORY
|
|
||||||
Write-Host "Resource Group is $resGroup"
|
|
||||||
Write-Host
|
|
||||||
$resourceGroup = Get-AzResourceGroup -name $resGroup -ErrorAction Ignore
|
|
||||||
if ($resourceGroup) {
|
|
||||||
Write-Host "Removing Resource Group $resGroup"
|
|
||||||
Remove-AzResourceGroup -Name $resGroup -Force | Out-Host
|
|
||||||
Write-Host "Done"
|
|
||||||
}
|
|
||||||
$runners = (gh api /repos/$repo/actions/runners | ConvertFrom-Json).runners
|
|
||||||
$runners | Where-Object { $_.status -eq "offline" } | ForEach-Object {
|
|
||||||
Write-host "Unregistering runner $($_.name)"
|
|
||||||
$id = $_.id
|
|
||||||
gh api -X DELETE /repos/$repo/actions/runners/$id
|
|
||||||
Write-Host "Done"
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Create Resource Group
|
|
||||||
uses: azure/powershell@v1
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
||||||
with:
|
|
||||||
azPSVersion: "latest"
|
|
||||||
inlineScript: |
|
|
||||||
$resGroup = $env:resGroup
|
|
||||||
$resLocation = $env:resLocation
|
|
||||||
Write-Host "Creating resource group $resGroup in $resLocation"
|
|
||||||
$resourceGroup = New-AzResourceGroup -Name $resGroup -Location $resLocation -Force
|
|
||||||
Write-Host "Done"
|
|
||||||
|
|
||||||
- name: Calculate Matrix
|
|
||||||
id: CalculateMatrix
|
|
||||||
env:
|
|
||||||
count: ${{ github.event.inputs.Count }}
|
|
||||||
run: |
|
|
||||||
$count = [int]$env:count
|
|
||||||
$matrix = @{ "machine" = @(1..$count) } | ConvertTo-Json -compress
|
|
||||||
Add-Content -path $ENV:GITHUB_OUTPUT -value "matrix=$matrix"
|
|
||||||
Write-Host $matrix
|
|
||||||
|
|
||||||
CreateAgents:
|
|
||||||
runs-on: [ windows-latest ]
|
|
||||||
needs: [ Preparation ]
|
|
||||||
strategy:
|
|
||||||
matrix: ${{fromJson(needs.Preparation.outputs.matrix)}}
|
|
||||||
fail-fast: true
|
|
||||||
steps:
|
|
||||||
- uses: azure/login@v1
|
|
||||||
with:
|
|
||||||
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
|
||||||
enable-AzPSSession: true
|
|
||||||
|
|
||||||
- name: Create Azure VM
|
|
||||||
uses: azure/powershell@v1
|
|
||||||
env:
|
|
||||||
machine: ${{ matrix.machine }}
|
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
||||||
with:
|
|
||||||
azPSVersion: "latest"
|
|
||||||
inlineScript: |
|
|
||||||
$resGroup = $env:resGroup
|
|
||||||
$repo = $env:GITHUB_REPOSITORY
|
|
||||||
$no = $env:machine
|
|
||||||
$templateUri = "https://raw.githubusercontent.com/microsoft/nav-arm-templates/$($env:ARMbranch)/$($env:ARMtemplate).json"
|
|
||||||
$registrationToken = (gh api -X POST /repos/$repo/actions/runners/registration-token | ConvertFrom-Json).token
|
|
||||||
$headers = @{
|
|
||||||
"Accept" = "application/json"
|
|
||||||
}
|
|
||||||
$uri = "https://api.github.com/repos/actions/runner/releases"
|
|
||||||
$result = Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri $uri
|
|
||||||
$releases = $result.Content | ConvertFrom-Json
|
|
||||||
$asset = $releases[0].assets | Where-Object { $_.name -like "actions-runner-win-x64-*.*.?.zip" }
|
|
||||||
$Parameters = @{
|
|
||||||
"VmName" = "$resgroup$no"
|
|
||||||
"Remotedesktopaccess" = "-"
|
|
||||||
"OperatingSystem" = "Windows Server 2022"
|
|
||||||
"VmSize" = "Standard_D4as_v5"
|
|
||||||
"OSDiskSize" = 1000
|
|
||||||
"StorageAccountType" = "Premium_LRS"
|
|
||||||
"AdminPassword" = [SecureString](ConvertTo-SecureString -String $env:GH_TOKEN -AsPlainText -Force)
|
|
||||||
"Count" = 1
|
|
||||||
"Token" = $registrationToken
|
|
||||||
"Organization" = "https://github.com/$repo"
|
|
||||||
"LabelsOrPool" = "buildgeneric"
|
|
||||||
"AgentUrl" = $asset.browser_download_url
|
|
||||||
"InstallHyperV" = "Yes"
|
|
||||||
"RunInsideDocker" = "No"
|
|
||||||
"FinalSetupScriptUrl" = "additional-installforbuildagent.ps1"
|
|
||||||
}
|
|
||||||
$resourceGroup = Get-AzResourceGroup -name $resGroup
|
|
||||||
$err = $resourceGroup | Test-AzResourceGroupDeployment -TemplateUri $templateUri -TemplateParameterObject $Parameters
|
|
||||||
if ($err) {
|
|
||||||
$err
|
|
||||||
throw "stop"
|
|
||||||
}
|
|
||||||
Write-Host "Creating Azure VM $($parameters.VmName)"
|
|
||||||
$resourceGroup | New-AzResourceGroupDeployment -TemplateUri $templateUri -TemplateParameterObject $Parameters -Name $Parameters.vmName -ErrorAction Ignore
|
|
||||||
Write-Host "Done"
|
|
|
@ -1,51 +0,0 @@
|
||||||
name: Remove Self-Hosted Agents
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
defaults:
|
|
||||||
run:
|
|
||||||
shell: PowerShell
|
|
||||||
|
|
||||||
env:
|
|
||||||
resGroup: "buildgeneric"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
Preparation:
|
|
||||||
runs-on: [ windows-latest ]
|
|
||||||
outputs:
|
|
||||||
matrix: ${{steps.CalculateMatrix.outputs.matrix}}
|
|
||||||
steps:
|
|
||||||
- name: Azure Login
|
|
||||||
uses: azure/login@v1
|
|
||||||
with:
|
|
||||||
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
|
||||||
enable-AzPSSession: true
|
|
||||||
|
|
||||||
- name: Remove Old Agents
|
|
||||||
uses: azure/powershell@v1
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
||||||
with:
|
|
||||||
azPSVersion: "latest"
|
|
||||||
inlineScript: |
|
|
||||||
$resGroup = $env:resGroup
|
|
||||||
$repo = $env:GITHUB_REPOSITORY
|
|
||||||
Write-Host "Resource Group is $resGroup"
|
|
||||||
Write-Host
|
|
||||||
$resourceGroup = Get-AzResourceGroup -name $resGroup -ErrorAction Ignore
|
|
||||||
if ($resourceGroup) {
|
|
||||||
Write-Host "Removing Resource Group $resGroup"
|
|
||||||
Remove-AzResourceGroup -Name $resGroup -Force | Out-Host
|
|
||||||
Write-Host "Done"
|
|
||||||
}
|
|
||||||
$runners = (gh api /repos/$repo/actions/runners | ConvertFrom-Json).runners
|
|
||||||
$runners | Where-Object { $_.status -eq "offline" } | ForEach-Object {
|
|
||||||
Write-host "Unregistering runner $($_.name)"
|
|
||||||
$id = $_.id
|
|
||||||
gh api -X DELETE /repos/$repo/actions/runners/$id
|
|
||||||
Write-Host "Done"
|
|
||||||
}
|
|
|
@ -1,96 +0,0 @@
|
||||||
name: Azure test
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-deploy:
|
|
||||||
runs-on: windows-latest
|
|
||||||
steps:
|
|
||||||
|
|
||||||
# Checkout code
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
# Log into Azure
|
|
||||||
- uses: azure/login@v1
|
|
||||||
with:
|
|
||||||
creds: ${{ secrets.AZURE_CREDENTIALS }}
|
|
||||||
enable-AzPSSession: true
|
|
||||||
|
|
||||||
- name: Run Azure PowerShell script
|
|
||||||
uses: azure/powershell@v1
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ secrets.GH_TOKEN }}
|
|
||||||
with:
|
|
||||||
azPSVersion: "latest"
|
|
||||||
inlineScript: |
|
|
||||||
$resGroup = "buildgeneric"
|
|
||||||
$resLocation = "West Europe"
|
|
||||||
$repo = "microsoft/nav-docker"
|
|
||||||
$machines = 2
|
|
||||||
$offset = 0
|
|
||||||
Write-Host "Resource Group is $resGroup"
|
|
||||||
$resourceGroup = Get-AzResourceGroup -name $resGroup -ErrorAction Ignore
|
|
||||||
if ($resourceGroup) {
|
|
||||||
Write-Host "Removing Resource Group $resGroup"
|
|
||||||
Remove-AzResourceGroup -Name $resGroup -Force | Out-Host
|
|
||||||
Write-Host "Done"
|
|
||||||
}
|
|
||||||
$runners = (gh api /repos/$repo/actions/runners | ConvertFrom-Json).runners
|
|
||||||
$runners | Where-Object { $_.status -eq "offline" } | ForEach-Object {
|
|
||||||
Write-host "Unregistering runner $($_.name)"
|
|
||||||
$id = $_.id
|
|
||||||
gh api -X DELETE /repos/$repo/actions/runners/$id
|
|
||||||
Write-Host "Done"
|
|
||||||
}
|
|
||||||
Write-Host "Creating resource group $resGroup in $resLocation"
|
|
||||||
$resourceGroup = New-AzResourceGroup -Name $resGroup -Location $resLocation -Force
|
|
||||||
Write-Host "Done"
|
|
||||||
1..$machines | ForEach-Object {
|
|
||||||
# Deployment
|
|
||||||
$no = $offset + $_
|
|
||||||
$branch = "dev"
|
|
||||||
$template = "buildagent"
|
|
||||||
|
|
||||||
# ARM template
|
|
||||||
$templateUri = "https://raw.githubusercontent.com/microsoft/nav-arm-templates/$branch/$template.json"
|
|
||||||
|
|
||||||
$registrationToken = (gh api -X POST /repos/$repo/actions/runners/registration-token | ConvertFrom-Json).token
|
|
||||||
$headers = @{
|
|
||||||
"Accept" = "application/json"
|
|
||||||
}
|
|
||||||
$uri = "https://api.github.com/repos/actions/runner/releases"
|
|
||||||
$result = Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri $uri
|
|
||||||
$releases = $result.Content | ConvertFrom-Json
|
|
||||||
$asset = $releases[0].assets | Where-Object { $_.name -like "actions-runner-win-x64-*.*.?.zip" }
|
|
||||||
|
|
||||||
$Parameters = @{
|
|
||||||
"VmName" = "$resgroup$no"
|
|
||||||
"Remotedesktopaccess" = "-"
|
|
||||||
"OperatingSystem" = "Windows Server 2022"
|
|
||||||
"VmSize" = "Standard_D4as_v5"
|
|
||||||
"OSDiskSize" = 128
|
|
||||||
"StorageAccountType" = "Premium_LRS"
|
|
||||||
"AdminPassword" = [SecureString](ConvertTo-SecureString -String $env:GH_TOKEN -AsPlainText -Force)
|
|
||||||
"Count" = 1
|
|
||||||
"Token" = $registrationToken
|
|
||||||
"Organization" = "https://github.com/$repo"
|
|
||||||
"LabelsOrPool" = "buildgeneric"
|
|
||||||
"AgentUrl" = $asset.browser_download_url
|
|
||||||
"InstallHyperV" = "Yes"
|
|
||||||
"RunInsideDocker" = "No"
|
|
||||||
"FinalSetupScriptUrl" = "additional-installforbuildagent.ps1"
|
|
||||||
}
|
|
||||||
|
|
||||||
$err = $resourceGroup | Test-AzResourceGroupDeployment -TemplateUri $templateUri -TemplateParameterObject $Parameters
|
|
||||||
if ($err) {
|
|
||||||
$err
|
|
||||||
throw "stop"
|
|
||||||
}
|
|
||||||
Write-Host "Creating Azure VM $($parameters.VmName)"
|
|
||||||
$resourceGroup | New-AzResourceGroupDeployment -TemplateUri $templateUri -TemplateParameterObject $Parameters -Name $Parameters.vmName -ErrorAction Ignore
|
|
||||||
Write-Host "Done"
|
|
||||||
}
|
|
|
@ -2,26 +2,54 @@ ARG baseimage
|
||||||
|
|
||||||
FROM $baseimage
|
FROM $baseimage
|
||||||
|
|
||||||
ARG created
|
ARG created \
|
||||||
ARG tag
|
tag \
|
||||||
ARG osversion
|
osversion \
|
||||||
|
filesonly \
|
||||||
|
only24
|
||||||
|
|
||||||
|
ENV only24=$only24 \
|
||||||
|
filesonly=$filesonly
|
||||||
|
|
||||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||||
|
|
||||||
# Install the prerequisites first to be able reuse the cache when changing only the scripts.
|
COPY Run /Run/
|
||||||
# Temporary workaround for Windows DNS client weirdness (need to check if the issue is still present or not).
|
|
||||||
|
|
||||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 ; \
|
RUN Write-Host ('FilesOnly='+$env:filesOnly); \
|
||||||
|
Write-Host ('only24='+$env:only24); \
|
||||||
|
$filesonly = $env:filesonly -eq 'true'; \
|
||||||
|
$only24 = $env:only24 -eq 'true'; \
|
||||||
|
if ($only24) { Remove-Item -Recurse -Force Run/70,Run/71,Run/80,Run/90,Run/100,Run/110,Run/130,Run/150,Run/150-new,Run/210,Run/210-new }; \
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 ; \
|
||||||
|
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.Filesystem') | Out-Null ; \
|
||||||
|
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord; \
|
||||||
|
Set-ItemProperty -Path 'HKLM:\system\CurrentControlSet\control' -name ServicesPipeTimeout -Value 300000 -Type DWORD -Force; \
|
||||||
|
New-Item 'temp' -ItemType Directory | Out-Null; \
|
||||||
|
if (-not $filesonly) { \
|
||||||
|
if ($only24) { \
|
||||||
|
Write-Host 'Adding Windows Features for BC 24+'; \
|
||||||
|
Add-WindowsFeature Web-Server,web-AppInit,web-Windows-Auth,web-Dyn-Compression,web-WebSockets; \
|
||||||
|
Stop-Service 'W3SVC' ; \
|
||||||
|
Set-Service 'W3SVC' -startuptype manual ; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
Write-Host 'Adding Windows Features for BC'; \
|
||||||
Add-WindowsFeature Web-Server,web-AppInit,web-Asp-Net45,web-Windows-Auth,web-Dyn-Compression,web-WebSockets; \
|
Add-WindowsFeature Web-Server,web-AppInit,web-Asp-Net45,web-Windows-Auth,web-Dyn-Compression,web-WebSockets; \
|
||||||
Stop-Service 'W3SVC' ; \
|
Stop-Service 'W3SVC' ; \
|
||||||
Set-Service 'W3SVC' -startuptype manual ; \
|
Set-Service 'W3SVC' -startuptype manual ; \
|
||||||
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord; \
|
} \
|
||||||
Set-ItemProperty -Path "HKLM:\system\CurrentControlSet\control" -name ServicesPipeTimeout -Value 300000 -Type DWORD -Force; \
|
Write-Host 'Downloading SQL Server 2019 Express'; \
|
||||||
Invoke-WebRequest -Uri 'https://bcartifacts.blob.core.windows.net/prerequisites/SQLEXPR2019_X64_ENU.EXE' -OutFile sqlexpress.exe ; \
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://go.microsoft.com/fwlink/p/?linkid=866658' -OutFile 'temp\SQL2019-SSEI-Expr.exe'; \
|
||||||
Start-Process -Wait -FilePath .\sqlexpress.exe -ArgumentList /qs, /x:setup ; \
|
$configFileLocation = 'c:\run\SQLConf.ini'; \
|
||||||
.\setup\setup.exe /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\Administrators' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS ; \
|
Write-Host 'Installing SQL Server 2019 Express'; \
|
||||||
While (!(get-service 'MSSQL$SQLEXPRESS' -ErrorAction SilentlyContinue)) { Start-Sleep -Seconds 5 } ; \
|
$process = Start-Process -FilePath 'temp\SQL2019-SSEI-Expr.exe' -ArgumentList /Action=Install, /ConfigurationFile=$configFileLocation, /IAcceptSQLServerLicenseTerms, /Quiet -NoNewWindow -Wait -PassThru; \
|
||||||
Stop-Service 'MSSQL$SQLEXPRESS' ; \
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
Write-Host 'Downloading SQL Server 2019 Cumulative Update'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://download.microsoft.com/download/6/e/7/6e72dddf-dfa4-4889-bc3d-e5d3a0fd11ce/SQLServer2019-KB5033688-x64.exe' -OutFile 'temp\SQL2019CU.exe'; \
|
||||||
|
Write-Host 'Installing SQL Server 2019 Cumulative Update'; \
|
||||||
|
$process = Start-Process -FilePath 'temp\SQL2019CU.exe' -ArgumentList /Action=Patch, /Quiet, /IAcceptSQLServerLicenseTerms, /AllInstances, /SuppressPrivacyStatementNotice -NoNewWindow -Wait -PassThru; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
Write-Host 'Configuring SQL Server 2019 Express'; \
|
||||||
Set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
|
Set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
|
||||||
Set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
|
Set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
|
||||||
Set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ; \
|
Set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ; \
|
||||||
|
@ -29,41 +57,79 @@ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::Sec
|
||||||
Set-Service 'SQLTELEMETRY$SQLEXPRESS' -startuptype manual ; \
|
Set-Service 'SQLTELEMETRY$SQLEXPRESS' -startuptype manual ; \
|
||||||
Set-Service 'SQLWriter' -startuptype manual ; \
|
Set-Service 'SQLWriter' -startuptype manual ; \
|
||||||
Set-Service 'SQLBrowser' -startuptype manual ; \
|
Set-Service 'SQLBrowser' -startuptype manual ; \
|
||||||
Remove-Item -Recurse -Force sqlexpress.exe, setup
|
Write-Host 'Removing SQL Server 2019 Express Install Files'; \
|
||||||
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'SQL2019'; \
|
||||||
COPY Run /Run/
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'C:\Program Files\Microsoft SQL Server\150\Setup Bootstrap'; \
|
||||||
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'C:\Program Files\Microsoft SQL Server\150\SSEI'; \
|
||||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 ; \
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'C:\Program Files\Microsoft SQL Server\MSSQL15.SQLEXPRESS\MSSQL\Template Data'; \
|
||||||
Invoke-WebRequest -Uri 'https://bcdocker.blob.core.windows.net/public/nav-docker-install.zip' -OutFile 'nav-docker-install.zip' ; \
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'C:\Program Files\Microsoft SQL Server\MSSQL15.SQLEXPRESS\MSSQL\Log\*'; \
|
||||||
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.Filesystem') | Out-Null ; \
|
} \
|
||||||
[System.IO.Compression.ZipFile]::ExtractToDirectory('.\nav-docker-install.zip', 'c:\run') ; \
|
Write-Host 'Downloading NAV/BC Docker Install Files'; \
|
||||||
Remove-Item -Force 'nav-docker-install.zip' ; \
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://bcdocker.blob.core.windows.net/public/nav-docker-install.zip' -OutFile 'temp\nav-docker-install.zip' ; \
|
||||||
|
Write-Host 'Extracting NAV/BC Docker Install Files'; \
|
||||||
|
[System.IO.Compression.ZipFile]::ExtractToDirectory('temp\nav-docker-install.zip', 'c:\run') ; \
|
||||||
|
Write-Host 'Updating PowerShell Execution Policy to Unrestricted'; \
|
||||||
. C:\Run\UpdatePowerShellExeConfig.ps1 ; \
|
. C:\Run\UpdatePowerShellExeConfig.ps1 ; \
|
||||||
. C:\Run\helperfunctions.ps1 ; \
|
. C:\Run\helperfunctions.ps1 ; \
|
||||||
|
if (-not $filesonly) { \
|
||||||
|
Write-Host 'Starting SQL Server Services'; \
|
||||||
Start-Service -Name $SqlBrowserServiceName -ErrorAction Ignore -WarningAction Ignore ; \
|
Start-Service -Name $SqlBrowserServiceName -ErrorAction Ignore -WarningAction Ignore ; \
|
||||||
Start-Service -Name $SqlWriterServiceName -ErrorAction Ignore -WarningAction Ignore ; \
|
Start-Service -Name $SqlWriterServiceName -ErrorAction Ignore -WarningAction Ignore ; \
|
||||||
Start-Service -Name $SqlServiceName -ErrorAction Ignore -WarningAction Ignore ; \
|
Start-Service -Name $SqlServiceName -ErrorAction Ignore -WarningAction Ignore ; \
|
||||||
Invoke-WebRequest -Uri 'https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi' -OutFile rewrite_amd64.msi ; \
|
Write-Host 'Downloading rewrite_amd64'; \
|
||||||
start-process -Wait -FilePath .\rewrite_amd64.msi -ArgumentList /quiet, /qn, /passive ; \
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi' -OutFile 'temp\rewrite_amd64.msi' ; \
|
||||||
Invoke-WebRequest -Uri 'https://bcartifacts.blob.core.windows.net/prerequisites/OpenXMLSDKv25.msi' -OutFile OpenXMLSDKV25.msi ; \
|
Write-Host 'Installing rewrite_amd64'; \
|
||||||
start-process -Wait -FilePath .\OpenXMLSDKV25.msi -ArgumentList /quiet, /qn, /passive ; \
|
$process = start-process -Wait -FilePath 'temp\rewrite_amd64.msi' -ArgumentList /quiet, /qn, /passive ; \
|
||||||
Invoke-WebRequest -Uri 'https://download.visualstudio.microsoft.com/download/pr/05726c49-3a3d-4862-9ff8-0660d9dc3c52/71c295f9287faad89e2d3233a38b44fb/dotnet-hosting-5.0.17-win.exe' -OutFile DotNet-Win5.exe ; \
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
start-process -Wait -FilePath .\DotNet-Win5.exe -ArgumentList /quiet ; \
|
Write-Host 'Downloading SQL Server Native Client'; \
|
||||||
Invoke-WebRequest -Uri 'https://download.visualstudio.microsoft.com/download/pr/04389c24-12a9-4e0e-8498-31989f30bb22/141aef28265938153eefad0f2398a73b/dotnet-hosting-6.0.27-win.exe' -OutFile DotNet6-Win.exe ; \
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://download.microsoft.com/download/B/E/D/BED73AAC-3C8A-43F5-AF4F-EB4FEA6C8F3A/ENU/x64/sqlncli.msi' -OutFile 'temp\sqlncli.msi' ; \
|
||||||
start-process -Wait -FilePath .\DotNet6-Win.exe -ArgumentList /quiet ; \
|
Write-Host 'Installing SQL Server Native Client'; \
|
||||||
Invoke-WebRequest -Uri 'https://download.visualstudio.microsoft.com/download/pr/98ff0a08-a283-428f-8e54-19841d97154c/8c7d5f9600eadf264f04c82c813b7aab/dotnet-hosting-8.0.2-win.exe' -OutFile DotNet8-Win.exe ; \
|
$process = start-process -Wait -FilePath 'temp\sqlncli.msi' -ArgumentList /quiet, /qn, /passive ; \
|
||||||
start-process -Wait -FilePath .\DotNet8-Win.exe -ArgumentList /quiet ; \
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
Invoke-WebRequest -Uri 'https://github.com/PowerShell/PowerShell/releases/download/v7.4.1/PowerShell-7.4.1-win-x64.msi' -OutFile powershell-7.4.1-win-x64.msi ; \
|
} \
|
||||||
start-process -Wait -FilePath .\powershell-7.4.1-win-x64.msi -ArgumentList /quiet ; \
|
Write-Host 'Downloading OpenXMLSDKV25'; \
|
||||||
Invoke-WebRequest -Uri 'https://download.microsoft.com/download/B/E/D/BED73AAC-3C8A-43F5-AF4F-EB4FEA6C8F3A/ENU/x64/sqlncli.msi' -OutFile sqlncli.msi ; \
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://bcartifacts.blob.core.windows.net/prerequisites/OpenXMLSDKv25.msi' -OutFile 'temp\OpenXMLSDKV25.msi' ; \
|
||||||
start-process -Wait -FilePath .\sqlncli.msi -ArgumentList /quiet, /qn, /passive ; \
|
Write-Host 'Installing OpenXMLSDKV25'; \
|
||||||
Invoke-WebRequest -Uri 'https://aka.ms/highdpimfc2013x86enu' -OutFile vcredist_x86.exe ; \
|
$process = start-process -Wait -FilePath 'temp\OpenXMLSDKV25.msi' -ArgumentList /quiet, /qn, /passive ; \
|
||||||
start-process -Wait -FilePath .\vcredist_x86.exe -ArgumentList /q, /norestart ; \
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
Invoke-WebRequest -Uri 'https://aka.ms/highdpimfc2013x64enu' -OutFile vcredist_x64.exe ; \
|
Write-Host 'Downloading dotnet 6'; \
|
||||||
start-process -Wait -FilePath .\vcredist_x64.exe -ArgumentList /q, /norestart ; \
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://download.visualstudio.microsoft.com/download/pr/04389c24-12a9-4e0e-8498-31989f30bb22/141aef28265938153eefad0f2398a73b/dotnet-hosting-6.0.27-win.exe' -OutFile 'temp\DotNet6-Win.exe' ; \
|
||||||
Invoke-WebRequest -Uri 'https://aka.ms/vs/17/release/vc_redist.x64.exe' -OutFile vcredist_x64_140.exe ; \
|
Write-Host 'Installing dotnet 6'; \
|
||||||
start-process -Wait -FilePath .\vcredist_x64_140.exe -ArgumentList /q, /norestart ; \
|
$process = start-process -Wait -FilePath 'temp\DotNet6-Win.exe' -ArgumentList /quiet ; \
|
||||||
Remove-Item -Recurse -Force rewrite_amd64.msi, OpenXMLSDKV25.msi, DotNet-Win5.exe, DotNet6-Win.exe, DotNet8-Win.exe, powershell-7.4.1-win-x64.msi, sqlncli.msi, vcredist_x86.exe, vcredist_x64.exe, vcredist_x64_140.exe
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
Write-Host 'Downloading dotnet 8'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://download.visualstudio.microsoft.com/download/pr/98ff0a08-a283-428f-8e54-19841d97154c/8c7d5f9600eadf264f04c82c813b7aab/dotnet-hosting-8.0.2-win.exe' -OutFile 'temp\DotNet8-Win.exe' ; \
|
||||||
|
Write-Host 'Installing dotnet 8'; \
|
||||||
|
$process = start-process -Wait -FilePath 'temp\DotNet8-Win.exe' -ArgumentList /quiet ; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
Write-Host 'Downloading PowerShell 7.4.1'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://github.com/PowerShell/PowerShell/releases/download/v7.4.1/PowerShell-7.4.1-win-x64.msi' -OutFile 'temp\powershell-7.4.1-win-x64.msi' ; \
|
||||||
|
Write-Host 'Installing PowerShell 7.4.1'; \
|
||||||
|
$process = start-process -Wait -FilePath 'temp\powershell-7.4.1-win-x64.msi' -ArgumentList /quiet ; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
if (-not $only24) { \
|
||||||
|
Write-Host 'Downloading vcredist_x86'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://aka.ms/highdpimfc2013x86enu' -OutFile 'temp\vcredist_x86.exe' ; \
|
||||||
|
Write-Host 'Installing vcredist_x86'; \
|
||||||
|
$process = start-process -Wait -FilePath 'temp\vcredist_x86.exe' -ArgumentList /q, /norestart ; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
Write-Host 'Downloading vcredist_x64'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://aka.ms/highdpimfc2013x64enu' -OutFile 'temp\vcredist_x64.exe' ; \
|
||||||
|
Write-Host 'Installing vcredist_x64'; \
|
||||||
|
$process = start-process -Wait -FilePath 'temp\vcredist_x64.exe' -ArgumentList /q, /norestart ; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
} \
|
||||||
|
Write-Host 'Downloading vcredist_x64_140'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://aka.ms/vs/17/release/vc_redist.x64.exe' -OutFile 'temp\vcredist_x64_140.exe' ; \
|
||||||
|
Write-Host 'Installing vcredist_x64_140'; \
|
||||||
|
$process = start-process -Wait -FilePath 'temp\vcredist_x64_140.exe' -ArgumentList /q, /norestart ; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
Write-Host 'Removing temp folder'; \
|
||||||
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'temp'; \
|
||||||
|
Write-Host 'Cleanup temporary files'; \
|
||||||
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $env:TEMP\*; \
|
||||||
|
Write-Host 'Remove x86 dotnet files'; \
|
||||||
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'C:\Program Files (x86)\dotnet'
|
||||||
|
|
||||||
HEALTHCHECK --interval=30s --timeout=10s CMD [ "powershell", ".\\Run\\HealthCheck.ps1" ]
|
HEALTHCHECK --interval=30s --timeout=10s CMD [ "powershell", ".\\Run\\HealthCheck.ps1" ]
|
||||||
|
|
||||||
|
|
|
@ -2,38 +2,138 @@ ARG baseimage
|
||||||
|
|
||||||
FROM $baseimage
|
FROM $baseimage
|
||||||
|
|
||||||
ARG created
|
ARG created \
|
||||||
ARG tag
|
tag \
|
||||||
ARG osversion
|
osversion \
|
||||||
|
filesonly \
|
||||||
|
only24
|
||||||
|
|
||||||
|
ENV only24=$only24 \
|
||||||
|
filesonly=$filesonly
|
||||||
|
|
||||||
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
|
||||||
|
|
||||||
COPY Run /Run/
|
COPY Run /Run/
|
||||||
|
|
||||||
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 ; \
|
RUN Write-Host ('FilesOnly='+$env:filesOnly); \
|
||||||
Invoke-WebRequest -Uri 'https://bcdocker.blob.core.windows.net/public/nav-docker-install.zip' -OutFile 'nav-docker-install.zip' ; \
|
Write-Host ('only24='+$env:only24); \
|
||||||
|
$filesonly = $env:filesonly -eq 'true'; \
|
||||||
|
$only24 = $env:only24 -eq 'true'; \
|
||||||
|
if ($only24) { Remove-Item -Recurse -Force Run/70,Run/71,Run/80,Run/90,Run/100,Run/110,Run/130,Run/150,Run/150-new,Run/210,Run/210-new }; \
|
||||||
|
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12 ; \
|
||||||
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.Filesystem') | Out-Null ; \
|
[Reflection.Assembly]::LoadWithPartialName('System.IO.Compression.Filesystem') | Out-Null ; \
|
||||||
[System.IO.Compression.ZipFile]::ExtractToDirectory('.\nav-docker-install.zip', 'c:\run') ; \
|
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord; \
|
||||||
Remove-Item -Force 'nav-docker-install.zip' ; \
|
Set-ItemProperty -Path 'HKLM:\system\CurrentControlSet\control' -name ServicesPipeTimeout -Value 300000 -Type DWORD -Force; \
|
||||||
|
New-Item 'temp' -ItemType Directory | Out-Null; \
|
||||||
|
if (-not $filesonly) { \
|
||||||
|
if ($only24) { \
|
||||||
|
Write-Host 'Adding Windows Features for BC 24+'; \
|
||||||
|
Add-WindowsFeature Web-Server,web-AppInit,web-Windows-Auth,web-Dyn-Compression,web-WebSockets; \
|
||||||
|
Stop-Service 'W3SVC' ; \
|
||||||
|
Set-Service 'W3SVC' -startuptype manual ; \
|
||||||
|
} \
|
||||||
|
else { \
|
||||||
|
Write-Host 'Adding Windows Features for BC'; \
|
||||||
|
Add-WindowsFeature Web-Server,web-AppInit,web-Asp-Net45,web-Windows-Auth,web-Dyn-Compression,web-WebSockets; \
|
||||||
|
Stop-Service 'W3SVC' ; \
|
||||||
|
Set-Service 'W3SVC' -startuptype manual ; \
|
||||||
|
} \
|
||||||
|
Write-Host 'Downloading SQL Server 2019 Express'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://go.microsoft.com/fwlink/p/?linkid=866658' -OutFile 'temp\SQL2019-SSEI-Expr.exe'; \
|
||||||
|
$configFileLocation = 'c:\run\SQLConf.ini'; \
|
||||||
|
Write-Host 'Installing SQL Server 2019 Express'; \
|
||||||
|
$process = Start-Process -FilePath 'temp\SQL2019-SSEI-Expr.exe' -ArgumentList /Action=Install, /ConfigurationFile=$configFileLocation, /IAcceptSQLServerLicenseTerms, /Quiet -NoNewWindow -Wait -PassThru; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
Write-Host 'Downloading SQL Server 2019 Cumulative Update'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://download.microsoft.com/download/6/e/7/6e72dddf-dfa4-4889-bc3d-e5d3a0fd11ce/SQLServer2019-KB5033688-x64.exe' -OutFile 'temp\SQL2019CU.exe'; \
|
||||||
|
Write-Host 'Installing SQL Server 2019 Cumulative Update'; \
|
||||||
|
$process = Start-Process -FilePath 'temp\SQL2019CU.exe' -ArgumentList /Action=Patch, /Quiet, /IAcceptSQLServerLicenseTerms, /AllInstances, /SuppressPrivacyStatementNotice -NoNewWindow -Wait -PassThru; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
Write-Host 'Configuring SQL Server 2019 Express'; \
|
||||||
|
Set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpdynamicports -value '' ; \
|
||||||
|
Set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.SQLEXPRESS\mssqlserver\supersocketnetlib\tcp\ipall' -name tcpport -value 1433 ; \
|
||||||
|
Set-itemproperty -path 'HKLM:\software\microsoft\microsoft sql server\mssql15.SQLEXPRESS\mssqlserver\' -name LoginMode -value 2 ; \
|
||||||
|
Set-Service 'MSSQL$SQLEXPRESS' -startuptype manual ; \
|
||||||
|
Set-Service 'SQLTELEMETRY$SQLEXPRESS' -startuptype manual ; \
|
||||||
|
Set-Service 'SQLWriter' -startuptype manual ; \
|
||||||
|
Set-Service 'SQLBrowser' -startuptype manual ; \
|
||||||
|
Write-Host 'Removing SQL Server 2019 Express Install Files'; \
|
||||||
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'SQL2019'; \
|
||||||
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'C:\Program Files\Microsoft SQL Server\150\Setup Bootstrap'; \
|
||||||
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'C:\Program Files\Microsoft SQL Server\150\SSEI'; \
|
||||||
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'C:\Program Files\Microsoft SQL Server\MSSQL15.SQLEXPRESS\MSSQL\Template Data'; \
|
||||||
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'C:\Program Files\Microsoft SQL Server\MSSQL15.SQLEXPRESS\MSSQL\Log\*'; \
|
||||||
|
} \
|
||||||
|
Write-Host 'Downloading NAV/BC Docker Install Files'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://bcdocker.blob.core.windows.net/public/nav-docker-install.zip' -OutFile 'temp\nav-docker-install.zip' ; \
|
||||||
|
Write-Host 'Extracting NAV/BC Docker Install Files'; \
|
||||||
|
[System.IO.Compression.ZipFile]::ExtractToDirectory('temp\nav-docker-install.zip', 'c:\run') ; \
|
||||||
|
Write-Host 'Updating PowerShell Execution Policy to Unrestricted'; \
|
||||||
. C:\Run\UpdatePowerShellExeConfig.ps1 ; \
|
. C:\Run\UpdatePowerShellExeConfig.ps1 ; \
|
||||||
. C:\Run\helperfunctions.ps1 ; \
|
. C:\Run\helperfunctions.ps1 ; \
|
||||||
Invoke-WebRequest -Uri 'https://bcartifacts.blob.core.windows.net/prerequisites/OpenXMLSDKv25.msi' -OutFile OpenXMLSDKV25.msi ; \
|
if (-not $filesonly) { \
|
||||||
start-process -Wait -FilePath .\OpenXMLSDKV25.msi -ArgumentList /quiet, /qn, /passive ; \
|
Write-Host 'Starting SQL Server Services'; \
|
||||||
Invoke-WebRequest -Uri 'https://download.visualstudio.microsoft.com/download/pr/05726c49-3a3d-4862-9ff8-0660d9dc3c52/71c295f9287faad89e2d3233a38b44fb/dotnet-hosting-5.0.17-win.exe' -OutFile DotNet-Win5.exe ; \
|
Start-Service -Name $SqlBrowserServiceName -ErrorAction Ignore -WarningAction Ignore ; \
|
||||||
start-process -Wait -FilePath .\DotNet-Win5.exe -ArgumentList /quiet ; \
|
Start-Service -Name $SqlWriterServiceName -ErrorAction Ignore -WarningAction Ignore ; \
|
||||||
Invoke-WebRequest -Uri 'https://download.visualstudio.microsoft.com/download/pr/04389c24-12a9-4e0e-8498-31989f30bb22/141aef28265938153eefad0f2398a73b/dotnet-hosting-6.0.27-win.exe' -OutFile DotNet6-Win.exe ; \
|
Start-Service -Name $SqlServiceName -ErrorAction Ignore -WarningAction Ignore ; \
|
||||||
start-process -Wait -FilePath .\DotNet6-Win.exe -ArgumentList /quiet ; \
|
Write-Host 'Downloading rewrite_amd64'; \
|
||||||
Invoke-WebRequest -Uri 'https://download.visualstudio.microsoft.com/download/pr/98ff0a08-a283-428f-8e54-19841d97154c/8c7d5f9600eadf264f04c82c813b7aab/dotnet-hosting-8.0.2-win.exe' -OutFile DotNet8-Win.exe ; \
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi' -OutFile 'temp\rewrite_amd64.msi' ; \
|
||||||
start-process -Wait -FilePath .\DotNet8-Win.exe -ArgumentList /quiet ; \
|
Write-Host 'Installing rewrite_amd64'; \
|
||||||
Invoke-WebRequest -Uri 'https://github.com/PowerShell/PowerShell/releases/download/v7.4.1/PowerShell-7.4.1-win-x64.msi' -OutFile powershell-7.4.1-win-x64.msi ; \
|
$process = start-process -Wait -FilePath 'temp\rewrite_amd64.msi' -ArgumentList /quiet, /qn, /passive ; \
|
||||||
start-process -Wait -FilePath .\powershell-7.4.1-win-x64.msi -ArgumentList /quiet ; \
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
Invoke-WebRequest -Uri 'https://aka.ms/highdpimfc2013x86enu' -OutFile vcredist_x86.exe ; \
|
Write-Host 'Downloading SQL Server Native Client'; \
|
||||||
start-process -Wait -FilePath .\vcredist_x86.exe -ArgumentList /q, /norestart ; \
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://download.microsoft.com/download/B/E/D/BED73AAC-3C8A-43F5-AF4F-EB4FEA6C8F3A/ENU/x64/sqlncli.msi' -OutFile 'temp\sqlncli.msi' ; \
|
||||||
Invoke-WebRequest -Uri 'https://aka.ms/highdpimfc2013x64enu' -OutFile vcredist_x64.exe ; \
|
Write-Host 'Installing SQL Server Native Client'; \
|
||||||
start-process -Wait -FilePath .\vcredist_x64.exe -ArgumentList /q, /norestart ; \
|
$process = start-process -Wait -FilePath 'temp\sqlncli.msi' -ArgumentList /quiet, /qn, /passive ; \
|
||||||
Invoke-WebRequest -Uri 'https://aka.ms/vs/17/release/vc_redist.x64.exe' -OutFile vcredist_x64_140.exe ; \
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
start-process -Wait -FilePath .\vcredist_x64_140.exe -ArgumentList /q, /norestart ; \
|
} \
|
||||||
Remove-Item -Recurse -Force OpenXMLSDKV25.msi, DotNet-Win5.exe, DotNet6-Win.exe, DotNet8-Win.exe, powershell-7.4.1-win-x64.msi, vcredist_x86.exe, vcredist_x64.exe, vcredist_x64_140.exe
|
Write-Host 'Downloading OpenXMLSDKV25'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://bcartifacts.blob.core.windows.net/prerequisites/OpenXMLSDKv25.msi' -OutFile 'temp\OpenXMLSDKV25.msi' ; \
|
||||||
|
Write-Host 'Installing OpenXMLSDKV25'; \
|
||||||
|
$process = start-process -Wait -FilePath 'temp\OpenXMLSDKV25.msi' -ArgumentList /quiet, /qn, /passive ; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
Write-Host 'Downloading dotnet 6'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://download.visualstudio.microsoft.com/download/pr/04389c24-12a9-4e0e-8498-31989f30bb22/141aef28265938153eefad0f2398a73b/dotnet-hosting-6.0.27-win.exe' -OutFile 'temp\DotNet6-Win.exe' ; \
|
||||||
|
Write-Host 'Installing dotnet 6'; \
|
||||||
|
$process = start-process -Wait -FilePath 'temp\DotNet6-Win.exe' -ArgumentList /quiet ; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
Write-Host 'Downloading dotnet 8'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://download.visualstudio.microsoft.com/download/pr/98ff0a08-a283-428f-8e54-19841d97154c/8c7d5f9600eadf264f04c82c813b7aab/dotnet-hosting-8.0.2-win.exe' -OutFile 'temp\DotNet8-Win.exe' ; \
|
||||||
|
Write-Host 'Installing dotnet 8'; \
|
||||||
|
$process = start-process -Wait -FilePath 'temp\DotNet8-Win.exe' -ArgumentList /quiet ; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
Write-Host 'Downloading PowerShell 7.4.1'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://github.com/PowerShell/PowerShell/releases/download/v7.4.1/PowerShell-7.4.1-win-x64.msi' -OutFile 'temp\powershell-7.4.1-win-x64.msi' ; \
|
||||||
|
Write-Host 'Installing PowerShell 7.4.1'; \
|
||||||
|
$process = start-process -Wait -FilePath 'temp\powershell-7.4.1-win-x64.msi' -ArgumentList /quiet ; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
if (-not $only24) { \
|
||||||
|
Write-Host 'Downloading vcredist_x86'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://aka.ms/highdpimfc2013x86enu' -OutFile 'temp\vcredist_x86.exe' ; \
|
||||||
|
Write-Host 'Installing vcredist_x86'; \
|
||||||
|
$process = start-process -Wait -FilePath 'temp\vcredist_x86.exe' -ArgumentList /q, /norestart ; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
Write-Host 'Downloading vcredist_x64'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://aka.ms/highdpimfc2013x64enu' -OutFile 'temp\vcredist_x64.exe' ; \
|
||||||
|
Write-Host 'Installing vcredist_x64'; \
|
||||||
|
$process = start-process -Wait -FilePath 'temp\vcredist_x64.exe' -ArgumentList /q, /norestart ; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
} \
|
||||||
|
Write-Host 'Downloading vcredist_x64_140'; \
|
||||||
|
Invoke-RestMethod -Method Get -UseBasicParsing -Uri 'https://aka.ms/vs/17/release/vc_redist.x64.exe' -OutFile 'temp\vcredist_x64_140.exe' ; \
|
||||||
|
Write-Host 'Installing vcredist_x64_140'; \
|
||||||
|
$process = start-process -Wait -FilePath 'temp\vcredist_x64_140.exe' -ArgumentList /q, /norestart ; \
|
||||||
|
if (($null -ne $process.ExitCode) -and ($process.ExitCode -ne 0)) { Write-Host ('EXIT CODE '+$process.ExitCode) } else { Write-Host 'Success' }; \
|
||||||
|
Write-Host 'Removing temp folder'; \
|
||||||
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'temp'; \
|
||||||
|
Write-Host 'Cleanup temporary files'; \
|
||||||
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue $env:TEMP\*; \
|
||||||
|
Write-Host 'Remove x86 dotnet files'; \
|
||||||
|
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue 'C:\Program Files (x86)\dotnet'
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=30s --timeout=10s CMD [ "powershell", ".\\Run\\HealthCheck.ps1" ]
|
||||||
|
|
||||||
|
EXPOSE 1433 80 8080 443 7045-7049 7083
|
||||||
|
|
||||||
CMD .\Run\start.ps1
|
CMD .\Run\start.ps1
|
||||||
|
|
||||||
|
|
|
@ -87,17 +87,10 @@ if (!$skipDb) {
|
||||||
Start-Service -name $IisServiceName
|
Start-Service -name $IisServiceName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Write-Host "Copying Service Tier Files"
|
Write-Host "Copying Service Tier Files"
|
||||||
RoboCopyFiles -Source "$NavDvdPath\ServiceTier\Program Files" -Destination "C:\Program Files" -e
|
RoboCopyFiles -Source "$NavDvdPath\ServiceTier\Program Files" -Destination "C:\Program Files" -e
|
||||||
RoboCopyFiles -Source "$NavDvdPath\ServiceTier\System64Folder" -Destination "C:\Windows\System32" -Files "NavSip.dll" -e
|
RoboCopyFiles -Source "$NavDvdPath\ServiceTier\System64Folder" -Destination "C:\Windows\System32" -Files "NavSip.dll" -e
|
||||||
|
|
||||||
Write-Host "Copying PowerShell Scripts"
|
|
||||||
RoboCopyFiles -Source "$navDvdPath\WindowsPowerShellScripts\Cloud\NAVAdministration" -Destination "$runPath\NAVAdministration" -e
|
|
||||||
if (Test-Path "$navDvdPath\WindowsPowerShellScripts\WebSearch") {
|
|
||||||
RoboCopyFiles -Source "$navDvdPath\WindowsPowerShellScripts\WebSearch" -Destination "$runPath\WebSearch" -e
|
|
||||||
}
|
|
||||||
|
|
||||||
Write-Host "Copying Web Client Files"
|
Write-Host "Copying Web Client Files"
|
||||||
RoboCopyFiles -Source "$NavDvdPath\WebClient\Microsoft Dynamics NAV" -Destination "C:\Program Files\Microsoft Dynamics NAV" -e
|
RoboCopyFiles -Source "$NavDvdPath\WebClient\Microsoft Dynamics NAV" -Destination "C:\Program Files\Microsoft Dynamics NAV" -e
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
;SQL Server 2019 Configuration File
|
||||||
|
[OPTIONS]
|
||||||
|
ACTION="Install"
|
||||||
|
SUPPRESSPRIVACYSTATEMENTNOTICE="True"
|
||||||
|
ENU="True"
|
||||||
|
QUIET="True"
|
||||||
|
SUPPRESSPAIDEDITIONNOTICE="True"
|
||||||
|
FEATURES=SQLENGINE
|
||||||
|
INSTANCENAME="SQLEXPRESS"
|
||||||
|
INSTALLSHAREDDIR="C:\Program Files\Microsoft SQL Server"
|
||||||
|
INSTALLSHAREDWOWDIR="C:\Program Files (x86)\Microsoft SQL Server"
|
||||||
|
INSTANCEID="SQLEXPRESS"
|
||||||
|
SQLTELSVCACCT="NT Service\SQLTELEMETRY$SQLEXPRESS"
|
||||||
|
SQLTELSVCSTARTUPTYPE="Manual"
|
||||||
|
INSTANCEDIR="C:\Program Files\Microsoft SQL Server"
|
||||||
|
AGTSVCACCOUNT="NT AUTHORITY\System"
|
||||||
|
AGTSVCSTARTUPTYPE="Disabled"
|
||||||
|
SQLSVCSTARTUPTYPE="Manual"
|
||||||
|
FILESTREAMLEVEL="0"
|
||||||
|
SQLMAXDOP="0"
|
||||||
|
ENABLERANU="False"
|
||||||
|
SQLCOLLATION="SQL_Latin1_General_CP1_CI_AS"
|
||||||
|
SQLSVCACCOUNT="NT AUTHORITY\System"
|
||||||
|
SQLSYSADMINACCOUNTS="BUILTIN\Administrators"
|
||||||
|
ADDCURRENTUSERASSQLADMIN="False"
|
||||||
|
TCPENABLED="1"
|
||||||
|
NPENABLED="0"
|
||||||
|
BROWSERSVCSTARTUPTYPE="Manual"
|
||||||
|
SQLMAXMEMORY="2147483647"
|
||||||
|
SQLMINMEMORY="0"
|
|
@ -125,7 +125,8 @@ else {
|
||||||
$roleTailoredClientFolder = ""
|
$roleTailoredClientFolder = ""
|
||||||
}
|
}
|
||||||
$WebClientFolder = (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Web Client")[0]
|
$WebClientFolder = (Get-Item "C:\Program Files\Microsoft Dynamics NAV\*\Web Client")[0]
|
||||||
$NAVAdministrationScriptsFolder = (Get-Item "$runPath\NAVAdministration").FullName
|
$NAVAdministrationScriptsFolder = "$runPath\NAVAdministration"
|
||||||
|
if (!(Test-Path $NAVAdministrationScriptsFolder)) { $NAVAdministrationScriptsFolder = '' }
|
||||||
$CustomConfigFile = Join-Path $serviceTierFolder "CustomSettings.config"
|
$CustomConfigFile = Join-Path $serviceTierFolder "CustomSettings.config"
|
||||||
$CustomConfig = [xml](Get-Content $CustomConfigFile)
|
$CustomConfig = [xml](Get-Content $CustomConfigFile)
|
||||||
$serverInstance = $CustomConfig.SelectSingleNode("//appSettings/add[@key='ServerInstance']").Value
|
$serverInstance = $CustomConfig.SelectSingleNode("//appSettings/add[@key='ServerInstance']").Value
|
||||||
|
|
|
@ -183,8 +183,8 @@ try {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($versionFolder) {
|
||||||
Write-Host "Using installer from $versionFolder"
|
Write-Host "Using installer from $versionFolder"
|
||||||
if ($versionFolder -ne "") {
|
|
||||||
if (Test-Path "c:\run\navinstall.ps1") {
|
if (Test-Path "c:\run\navinstall.ps1") {
|
||||||
Write-Host "navinstall was overridden"
|
Write-Host "navinstall was overridden"
|
||||||
Remove-Item "$versionFolder\navinstall.ps1"
|
Remove-Item "$versionFolder\navinstall.ps1"
|
||||||
|
@ -199,6 +199,9 @@ try {
|
||||||
}
|
}
|
||||||
Copy-Item -Path "$versionFolder\*" -Destination "C:\Run" -Recurse -Force
|
Copy-Item -Path "$versionFolder\*" -Destination "C:\Run" -Recurse -Force
|
||||||
}
|
}
|
||||||
|
elseif (!(Test-Path 'c:\run\navinstall.ps1')) {
|
||||||
|
throw "No installer found to use for version $versionNo"
|
||||||
|
}
|
||||||
|
|
||||||
# Remove version specific folders
|
# Remove version specific folders
|
||||||
Get-ChildItem -Path "C:\Run" -Directory | where-object { [Int]::TryParse($_.Name, [ref]$null) } | % {
|
Get-ChildItem -Path "C:\Run" -Directory | where-object { [Int]::TryParse($_.Name, [ref]$null) } | % {
|
||||||
|
|
|
@ -1,23 +1,31 @@
|
||||||
$RootPath = $PSScriptRoot
|
$RootPath = $PSScriptRoot
|
||||||
|
$ErrorActionPreference = "stop"
|
||||||
|
Set-StrictMode -Version 2.0
|
||||||
|
|
||||||
. (Join-Path $RootPath "settings.ps1")
|
$osVersion = [System.Version]'10.0.19042.1889' # 20H2
|
||||||
|
$osVersion = [System.Version]'10.0.19041.1415' # 2004
|
||||||
|
|
||||||
|
$isolation = "hyperv"
|
||||||
$filesOnly = $false
|
$filesOnly = $false
|
||||||
$os = (Get-CimInstance Win32_OperatingSystem)
|
$only24 = $false
|
||||||
if ($os.OSType -ne 18 -or !$os.Version.StartsWith("10.0.")) {
|
$image = "mygeneric"
|
||||||
throw "Unknown Host Operating System"
|
$genericTag = (Get-Content -Raw -Path (Join-Path $RootPath 'tag.txt')).Trim(@(13,10,32))
|
||||||
|
$created = [DateTime]::Now.ToUniversalTime().ToString("yyyyMMddHHmm")
|
||||||
|
|
||||||
|
Write-Host "Using OS Version $osVersion"
|
||||||
|
|
||||||
|
if ($only24) {
|
||||||
|
$baseimage = "mcr.microsoft.com/windows/servercore:$osVersion"
|
||||||
}
|
}
|
||||||
$UBR = (Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name UBR).UBR
|
else {
|
||||||
$hostOsVersion = [System.Version]::Parse("$($os.Version).$UBR")
|
|
||||||
|
|
||||||
Write-Host "Host OS Version is $hostOsVersion"
|
|
||||||
|
|
||||||
$baseImage = ""
|
$baseImage = ""
|
||||||
$webclient = New-Object System.Net.WebClient
|
$webclient = New-Object System.Net.WebClient
|
||||||
$basetags = (Get-NavContainerImageTags -imageName "mcr.microsoft.com/dotnet/framework/runtime").tags | Where-Object { $_.StartsWith('4.8-20') } | Sort-Object -Descending | Where-Object { -not $_.endswith("-1803") }
|
$basetags = (Get-NavContainerImageTags -imageName "mcr.microsoft.com/dotnet/framework/runtime").tags | Where-Object { $_.StartsWith('4.8-20') } | Sort-Object -Descending | Where-Object { -not $_.endswith("-1803") }
|
||||||
$basetags | ForEach-Object {
|
$basetags | ForEach-Object {
|
||||||
if (!($baseImage)) {
|
if (!($baseImage)) {
|
||||||
$manifest = (($webclient.DownloadString("https://mcr.microsoft.com/v2/dotnet/framework/runtime/manifests/$_") | ConvertFrom-Json).history[0].v1Compatibility | ConvertFrom-Json)
|
$manifest = (($webclient.DownloadString("https://mcr.microsoft.com/v2/dotnet/framework/runtime/manifests/$_") | ConvertFrom-Json).history[0].v1Compatibility | ConvertFrom-Json)
|
||||||
if ($hostOsVersion -eq $manifest.'os.version') {
|
Write-Host "$osVersion == $($manifest.'os.version')"
|
||||||
|
if ($osVersion -eq $manifest.'os.version') {
|
||||||
$baseImage = "mcr.microsoft.com/dotnet/framework/runtime:$_"
|
$baseImage = "mcr.microsoft.com/dotnet/framework/runtime:$_"
|
||||||
Write-Host "$baseImage matches the host OS version"
|
Write-Host "$baseImage matches the host OS version"
|
||||||
}
|
}
|
||||||
|
@ -26,27 +34,19 @@ $basetags | ForEach-Object {
|
||||||
if (!($baseImage)) {
|
if (!($baseImage)) {
|
||||||
Write-Error "Unable to find a matching mcr.microsoft.com/dotnet/framework/runtime docker image"
|
Write-Error "Unable to find a matching mcr.microsoft.com/dotnet/framework/runtime docker image"
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
|
||||||
if ($filesOnly) {
|
|
||||||
$dockerfile = Join-Path $RootPath "DOCKERFILE-filesonly"
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$dockerfile = Join-Path $RootPath "DOCKERFILE"
|
$dockerfile = Join-Path $RootPath "DOCKERFILE"
|
||||||
|
if ($only24) {
|
||||||
|
$image += "-24"
|
||||||
|
}
|
||||||
|
if ($filesOnly) {
|
||||||
|
$dockerfile += '-filesonly'
|
||||||
|
$image += '-filesonly'
|
||||||
}
|
}
|
||||||
|
|
||||||
$image = "mygeneric"
|
|
||||||
|
|
||||||
docker pull $baseimage
|
docker pull $baseimage
|
||||||
$osversion = docker inspect --format "{{.OsVersion}}" $baseImage
|
$osversion = docker inspect --format "{{.OsVersion}}" $baseImage
|
||||||
|
|
||||||
if ($hostOsVersion.Build -ge 20348 -or $osversion.Build -eq $hostOsVersion.Build) {
|
|
||||||
$isolation = "process"
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$isolation = "hyperv"
|
|
||||||
}
|
|
||||||
|
|
||||||
docker images --format "{{.Repository}}:{{.Tag}}" | % {
|
docker images --format "{{.Repository}}:{{.Tag}}" | % {
|
||||||
if ($_ -eq $image)
|
if ($_ -eq $image)
|
||||||
{
|
{
|
||||||
|
@ -58,7 +58,10 @@ else {
|
||||||
--build-arg created=$created `
|
--build-arg created=$created `
|
||||||
--build-arg tag="$genericTag" `
|
--build-arg tag="$genericTag" `
|
||||||
--build-arg osversion="$osversion" `
|
--build-arg osversion="$osversion" `
|
||||||
|
--build-arg filesonly="$filesonly" `
|
||||||
|
--build-arg only24="$only24" `
|
||||||
--isolation=$isolation `
|
--isolation=$isolation `
|
||||||
|
--memory 64G `
|
||||||
--tag $image `
|
--tag $image `
|
||||||
--file $dockerfile `
|
--file $dockerfile `
|
||||||
$RootPath
|
$RootPath
|
||||||
|
@ -69,4 +72,3 @@ else {
|
||||||
else {
|
else {
|
||||||
Write-Host "SUCCESS"
|
Write-Host "SUCCESS"
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
1.0.2.16
|
1.0.2.17
|
||||||
|
|
Загрузка…
Ссылка в новой задаче