Skip to content

Commit 92ffb18

Browse files
authored
Merge pull request #787 from lemeurherve/helpdesk4029-switch-off-from-eclipse-temurin-base-images-windows
feat(Windows): switch from temurin base images to temurin installer
2 parents be371a3 + dd88be6 commit 92ffb18

File tree

6 files changed

+46
-18
lines changed

6 files changed

+46
-18
lines changed

build-windows.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services:
66
dockerfile: ./windows/${WINDOWS_FLAVOR}/Dockerfile
77
args:
88
JAVA_HOME: "C:/openjdk-11"
9-
JAVA_VERSION: 11.0.23_9
9+
JAVA_VERSION: 11.0.23+9
1010
VERSION: ${REMOTING_VERSION}
1111
WINDOWS_VERSION_TAG: ${WINDOWS_VERSION_TAG}
1212
TOOLS_WINDOWS_VERSION: ${TOOLS_WINDOWS_VERSION}
@@ -19,7 +19,7 @@ services:
1919
dockerfile: ./windows/${WINDOWS_FLAVOR}/Dockerfile
2020
args:
2121
JAVA_HOME: "C:/openjdk-17"
22-
JAVA_VERSION: 17.0.10_7
22+
JAVA_VERSION: 17.0.10+7
2323
VERSION: ${REMOTING_VERSION}
2424
WINDOWS_VERSION_TAG: ${WINDOWS_VERSION_TAG}
2525
TOOLS_WINDOWS_VERSION: ${TOOLS_WINDOWS_VERSION}
@@ -34,7 +34,7 @@ services:
3434
dockerfile: ./windows/${WINDOWS_FLAVOR}/Dockerfile
3535
args:
3636
JAVA_HOME: "C:/openjdk-21"
37-
JAVA_VERSION: "21_35"
37+
JAVA_VERSION: 21+35
3838
VERSION: ${REMOTING_VERSION}
3939
WINDOWS_VERSION_TAG: ${WINDOWS_VERSION_TAG}
4040
TOOLS_WINDOWS_VERSION: ${TOOLS_WINDOWS_VERSION}

build.ps1

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@ Param(
1010
)
1111

1212
$ErrorActionPreference = 'Stop'
13+
14+
$originalDockerComposeFile = 'build-windows.yaml'
15+
$finalDockerComposeFile = 'build-windows-current.yaml'
16+
$baseDockerCmd = 'docker-compose --file={0}' -f $finalDockerComposeFile
17+
$baseDockerBuildCmd = '{0} build --parallel --pull' -f $baseDockerCmd
18+
1319
$AgentTypes = @('agent', 'inbound-agent')
1420
if ($AgentType -ne '' -and $AgentType -in $AgentTypes) {
1521
$AgentTypes = @($AgentType)
@@ -102,13 +108,15 @@ function Test-Image {
102108
$items = $AgentTypeAndImageName.Split("|")
103109
$agentType = $items[0]
104110
$imageName = $items[1]
111+
$javaVersion = $items[2]
105112
$imageNameItems = $imageName.Split(":")
106113
$imageTag = $imageNameItems[1]
107114

108115
Write-Host "= TEST: Testing ${imageName} image:"
109116

110117
$env:IMAGE_NAME = $imageName
111118
$env:VERSION = "$RemotingVersion"
119+
$env:JAVA_VERSION = "$javaVersion"
112120

113121
$targetPath = '.\target\{0}\{1}' -f $agentType, $imageTag
114122
if(Test-Path $targetPath) {
@@ -128,15 +136,11 @@ function Test-Image {
128136

129137
Remove-Item env:\IMAGE_NAME
130138
Remove-Item env:\VERSION
139+
Remove-Item env:\JAVA_VERSION
131140

132141
return $failed
133142
}
134143

135-
$originalDockerComposeFile = 'build-windows.yaml'
136-
$finalDockerComposeFile = 'build-windows-current.yaml'
137-
$baseDockerCmd = 'docker-compose --file={0}' -f $finalDockerComposeFile
138-
$baseDockerBuildCmd = '{0} build --parallel --pull' -f $baseDockerCmd
139-
140144
foreach($agentType in $AgentTypes) {
141145
# Ensure remaining env vars used in the docker compose file are defined
142146
$env:AGENT_TYPE = $agentType
@@ -196,8 +200,9 @@ foreach($agentType in $AgentTypes) {
196200
Write-Host "= TEST: Testing all ${agentType} images..."
197201
# Only fail the run afterwards in case of any test failures
198202
$testFailed = $false
199-
Invoke-Expression "$baseDockerCmd config" | yq '.services[].image' | ForEach-Object {
200-
$testFailed = $testFailed -or (Test-Image ('{0}|{1}' -f $agentType, $_))
203+
$jdks = Invoke-Expression "$baseDockerCmd config" | yq -r --output-format json '.services' | ConvertFrom-Json
204+
foreach ($jdk in $jdks.PSObject.Properties) {
205+
$testFailed = $testFailed -or (Test-Image ('{0}|{1}|{2}' -f $agentType, $jdk.Value.image, $jdk.Value.build.args.JAVA_VERSION))
201206
}
202207

203208
# Fail if any test failures

tests/agent.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Import-Module -DisableNameChecking -Force $PSScriptRoot/test_helpers.psm1
22

33
$global:IMAGE_NAME = Get-EnvOrDefault 'IMAGE_NAME' ''
44
$global:VERSION = Get-EnvOrDefault 'VERSION' ''
5+
$global:JAVA_VERSION = Get-EnvOrDefault 'JAVA_VERSION' ''
56

67
$imageItems = $global:IMAGE_NAME.Split(":")
78
$GLOBAL:IMAGE_TAG = $imageItems[1]
@@ -59,7 +60,6 @@ Describe "[$global:IMAGE_NAME] image has correct applications in the PATH" {
5960
It 'has java installed and in the path' {
6061
$exitCode, $stdout, $stderr = Run-Program 'docker' "exec $global:CONTAINERNAME $global:CONTAINERSHELL -C `"if(`$null -eq (Get-Command java.exe -ErrorAction SilentlyContinue)) { exit -1 } else { exit 0 }`""
6162
$exitCode | Should -Be 0
62-
6363
$exitCode, $stdout, $stderr = Run-Program 'docker' "exec $global:CONTAINERNAME $global:CONTAINERSHELL -C `"`$global:VERSION = java -version 2>&1 ; Write-Host `$global:VERSION`""
6464
$r = [regex] "^openjdk version `"(?<major>\d+)"
6565
$m = $r.Match($stdout)
@@ -150,7 +150,7 @@ Describe "[$global:IMAGE_NAME] can be built with custom build arguments" {
150150
BeforeAll {
151151
Push-Location -StackName 'agent' -Path "$PSScriptRoot/.."
152152

153-
$exitCode, $stdout, $stderr = Run-Program 'docker' "build --target agent --build-arg `"VERSION=${global:TEST_VERSION}`" --build-arg `"WINDOWS_VERSION_TAG=${global:WINDOWSVERSIONTAG}`" --build-arg `"TOOLS_WINDOWS_VERSION=${global:WINDOWSVERSIONFALLBACKTAG}`" --build-arg `"user=${global:TEST_USER}`" --build-arg `"AGENT_WORKDIR=${global:TEST_AGENT_WORKDIR}`" --tag ${global:IMAGE_NAME} --file ./windows/${global:WINDOWSFLAVOR}/Dockerfile ."
153+
$exitCode, $stdout, $stderr = Run-Program 'docker' "build --target agent --build-arg `"VERSION=${global:TEST_VERSION}`" --build-arg `"JAVA_VERSION=${global:JAVA_VERSION}`" --build-arg `"JAVA_HOME=C:\openjdk-${global:JAVAMAJORVERSION}`" --build-arg `"WINDOWS_VERSION_TAG=${global:WINDOWSVERSIONTAG}`" --build-arg `"TOOLS_WINDOWS_VERSION=${global:WINDOWSVERSIONFALLBACKTAG}`" --build-arg `"user=${global:TEST_USER}`" --build-arg `"AGENT_WORKDIR=${global:TEST_AGENT_WORKDIR}`" --tag ${global:IMAGE_NAME} --file ./windows/${global:WINDOWSFLAVOR}/Dockerfile ."
154154
$exitCode | Should -Be 0
155155

156156
$exitCode, $stdout, $stderr = Run-Program 'docker' "run -d -it --name $global:CONTAINERNAME -P $global:IMAGE_NAME $global:CONTAINERSHELL"

tests/inbound-agent.Tests.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ Import-Module -DisableNameChecking -Force $PSScriptRoot/test_helpers.psm1
22

33
$global:IMAGE_NAME = Get-EnvOrDefault 'IMAGE_NAME' ''
44
$global:VERSION = Get-EnvOrDefault 'VERSION' ''
5+
$global:JAVA_VERSION = Get-EnvOrDefault 'JAVA_VERSION' ''
56

67
$imageItems = $global:IMAGE_NAME.Split(":")
78
$GLOBAL:IMAGE_TAG = $imageItems[1]
@@ -34,7 +35,7 @@ BuildNcatImage($global:WINDOWSVERSIONTAG)
3435

3536
Describe "[$global:IMAGE_NAME] build image" {
3637
It 'builds image' {
37-
$exitCode, $stdout, $stderr = Run-Program 'docker' "build --build-arg VERSION=${global:VERSION} --build-arg `"WINDOWS_VERSION_TAG=${global:WINDOWSVERSIONTAG}`" --build-arg `"JAVA_VERSION=${global:JAVAMAJORVERSION}`" --build-arg `"JAVA_HOME=C:\openjdk-${global:JAVAMAJORVERSION}`" --tag=${global:IMAGE_TAG} --file ./windows/${global:WINDOWSFLAVOR}/Dockerfile ."
38+
$exitCode, $stdout, $stderr = Run-Program 'docker' "build --build-arg `"VERSION=${global:VERSION}`" --build-arg `"JAVA_VERSION=${global:JAVA_VERSION}`" --build-arg `"JAVA_HOME=C:\openjdk-${global:JAVAMAJORVERSION}`" --build-arg `"WINDOWS_VERSION_TAG=${global:WINDOWSVERSIONTAG}`" --tag=${global:IMAGE_TAG} --file ./windows/${global:WINDOWSFLAVOR}/Dockerfile ."
3839
$exitCode | Should -Be 0
3940
}
4041
}
@@ -123,7 +124,7 @@ Describe "[$global:IMAGE_NAME] custom build args" {
123124
}
124125

125126
It 'builds image with arguments' {
126-
$exitCode, $stdout, $stderr = Run-Program 'docker' "build --build-arg VERSION=${TEST_VERSION} --build-arg `"WINDOWS_VERSION_TAG=${global:WINDOWSVERSIONTAG}`" --build-arg `"JAVA_VERSION=${global:JAVAMAJORVERSION}`" --build-arg `"JAVA_HOME=C:\openjdk-${global:JAVAMAJORVERSION}`" --build-arg WINDOWS_FLAVOR=${global:WINDOWSFLAVOR} --build-arg CONTAINER_SHELL=${global:CONTAINERSHELL} --tag=${customImageName} --file=./windows/${global:WINDOWSFLAVOR}/Dockerfile ."
127+
$exitCode, $stdout, $stderr = Run-Program 'docker' "build --build-arg `"VERSION=${TEST_VERSION}`" --build-arg `"JAVA_VERSION=${global:JAVA_VERSION}`" --build-arg `"JAVA_HOME=C:\openjdk-${global:JAVAMAJORVERSION}`" --build-arg `"WINDOWS_VERSION_TAG=${global:WINDOWSVERSIONTAG}`" --build-arg WINDOWS_FLAVOR=${global:WINDOWSFLAVOR} --build-arg CONTAINER_SHELL=${global:CONTAINERSHELL} --tag=${customImageName} --file=./windows/${global:WINDOWSFLAVOR}/Dockerfile ."
127128
$exitCode | Should -Be 0
128129

129130
$exitCode, $stdout, $stderr = Run-Program 'docker' "run --detach --tty --name $global:CONTAINERNAME $customImageName -Cmd $global:CONTAINERSHELL"

windows/nanoserver/Dockerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,21 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
# THE SOFTWARE.
2424

25-
ARG JAVA_VERSION=17.0.7_7
2625
ARG WINDOWS_VERSION_TAG=ltsc2019
2726
ARG TOOLS_WINDOWS_VERSION=1809
28-
FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-windowsservercore-"${TOOLS_WINDOWS_VERSION}" AS jdk-core
27+
FROM mcr.microsoft.com/windows/servercore:"${WINDOWS_VERSION_TAG}" AS jdk-core
28+
29+
# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324
30+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
31+
32+
ARG JAVA_VERSION=17.0.10+7
33+
RUN New-Item -ItemType Directory -Path C:\temp | Out-Null ; `
34+
$javaMajorVersion = $env:JAVA_VERSION.substring(0,2) ; `
35+
$msiUrl = 'https://api.adoptium.net/v3/installer/version/jdk-{0}/windows/x64/jdk/hotspot/normal/eclipse?project=jdk' -f $env:JAVA_VERSION.Replace('+', '%2B') ; `
36+
Invoke-WebRequest $msiUrl -OutFile 'C:\temp\jdk.msi' ; `
37+
$proc = Start-Process -FilePath 'msiexec.exe' -ArgumentList '/i', 'C:\temp\jdk.msi', '/L*V', 'C:\temp\OpenJDK.log', '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', "INSTALLDIR=C:\openjdk-${javaMajorVersion}" -Wait -Passthru ; `
38+
$proc.WaitForExit() ; `
39+
Remove-Item -Path C:\temp -Recurse | Out-Null
2940

3041
FROM mcr.microsoft.com/powershell:nanoserver-"${TOOLS_WINDOWS_VERSION}" AS pwsh-source
3142

windows/windowsservercore/Dockerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,21 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2323
# THE SOFTWARE.
2424

25-
ARG JAVA_VERSION=17.0.7_7
2625
ARG WINDOWS_VERSION_TAG=ltsc2019
2726
ARG TOOLS_WINDOWS_VERSION=1809
28-
FROM eclipse-temurin:"${JAVA_VERSION}"-jdk-windowsservercore-"${TOOLS_WINDOWS_VERSION}" AS jdk-core
27+
FROM mcr.microsoft.com/windows/servercore:"${WINDOWS_VERSION_TAG}" AS jdk-core
28+
29+
# $ProgressPreference: https://github.com/PowerShell/PowerShell/issues/2138#issuecomment-251261324
30+
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
31+
32+
ARG JAVA_VERSION=17.0.10+7
33+
RUN New-Item -ItemType Directory -Path C:\temp | Out-Null ; `
34+
$javaMajorVersion = $env:JAVA_VERSION.substring(0,2) ; `
35+
$msiUrl = 'https://api.adoptium.net/v3/installer/version/jdk-{0}/windows/x64/jdk/hotspot/normal/eclipse?project=jdk' -f $env:JAVA_VERSION.Replace('+', '%2B') ; `
36+
Invoke-WebRequest $msiUrl -OutFile 'C:\temp\jdk.msi' ; `
37+
$proc = Start-Process -FilePath 'msiexec.exe' -ArgumentList '/i', 'C:\temp\jdk.msi', '/L*V', 'C:\temp\OpenJDK.log', '/quiet', 'ADDLOCAL=FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome', "INSTALLDIR=C:\openjdk-${javaMajorVersion}" -Wait -Passthru ; `
38+
$proc.WaitForExit() ; `
39+
Remove-Item -Path C:\temp -Recurse | Out-Null
2940

3041
## Agent image target
3142
FROM mcr.microsoft.com/windows/servercore:"${WINDOWS_VERSION_TAG}" AS agent

0 commit comments

Comments
 (0)