Skip to content

Commit 9e562af

Browse files
committed
fix: switch to Adoptium Temurin installer instead of Docker image
It introduces the following changes: - Faster build due to less layers to pull (ref. jenkinsci/docker-agent#787) - Retrieving the `netapi32` DLL and `whoami.exe`` from the Python parent image instead of Temurin image - Moving `ARG JAVA_VERSION` into the last stage's scope - Pin JDK21 version to 21+35 to ensure a valid installer is retrieved Signed-off-by: Damien Duportal <[email protected]>
1 parent 49f9c8c commit 9e562af

File tree

4 files changed

+76
-54
lines changed

4 files changed

+76
-54
lines changed

maven/jdk11/Dockerfile.nanoserver

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,44 @@
11
# escape=`
2-
ARG JAVA_VERSION=11.0.22_7
32
ARG JAVA17_IMAGE_VERSION=3206.vb_15dcf73f6a_9-2
43
ARG PYTHON_VERSION=3.12.2
54

6-
FROM python:"${PYTHON_VERSION}"-windowsservercore-1809 AS python
5+
FROM python:"${PYTHON_VERSION}"-windowsservercore-1809 AS python-core
6+
7+
# ProgressPreference => Disable Progress bar for faster downloads
8+
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
79

810
# hadolint ignore=DL3013
911
RUN "C:/Python/python.exe" -m pip install --no-cache-dir --upgrade pip; `
1012
pip install --no-cache-dir setuptools wheel;
1113

12-
FROM eclipse-temurin:${JAVA_VERSION}-jdk-windowsservercore-1809 AS core
14+
# Adding jdk11 from Adoptium MSI installer (cannot only run msiexec.exe on ServerCore, NOT on nanoserver)
15+
ARG JAVA_VERSION=jdk-11.0.22+7
16+
RUN New-Item -ItemType Directory -Path C:\temp | Out-Null ; `
17+
$msiUrl = 'https://api.adoptium.net/v3/installer/version/{0}/windows/x64/jdk/hotspot/normal/eclipse?project=jdk' -f $env:JAVA_VERSION.Replace('+', '%2B') ; `
18+
Invoke-WebRequest $msiUrl -OutFile 'C:\temp\jdk.msi' ; `
19+
$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:\javaruntime' -Wait -Passthru ; `
20+
$proc.WaitForExit() ; `
21+
Remove-Item -Path C:\temp -Recurse | Out-Null
22+
23+
# Use inbound-agent's jdk17 only for running jenkins agent, not as default java
1324
FROM jenkins/inbound-agent:"${JAVA17_IMAGE_VERSION}"-jdk17-nanoserver-1809
1425

1526
# ProgressPreference => Disable Progress bar for faster downloads
1627
SHELL ["pwsh.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
1728

1829
# Adding python
19-
COPY --from=python C:/Python C:/tools/python
30+
COPY --from=python-core C:/Python C:/tools/python
2031

2132
# Install Launchable in this layer
2233
ARG LAUNCHABLE_VERSION=1.66.0
2334
RUN "C:/tools/python/python.exe" -m pip install --no-cache-dir launchable=="${env:LAUNCHABLE_VERSION}";
2435

25-
# Adding jdk11 from eclipse-temurin
26-
# Use ENV and not ARG : https://docs.docker.com/engine/reference/builder/#using-arg-variables
2736
ENV JAVA_HOME="C:\tools\jdk-11"
28-
COPY --from=core C:/openjdk-11 "${JAVA_HOME}"
37+
COPY --from=python-core C:/javaruntime $JAVA_HOME
2938

3039
# https://github.com/StefanScherer/dockerfiles-windows/tree/master/golang-issue-21867
31-
COPY --from=core C:/windows/system32/netapi32.dll C:/windows/system32/netapi32.dll
40+
COPY --from=python-core C:/windows/system32/netapi32.dll C:/windows/system32/netapi32.dll
41+
COPY --from=python-core C:/windows/system32/whoami.exe C:/windows/system32/whoami.exe
3242

3343
ARG MAVEN_VERSION=3.9.6
3444
RUN Invoke-WebRequest -Uri "https://archive.apache.org/dist/maven/maven-3/${env:MAVEN_VERSION}/binaries/apache-maven-${env:MAVEN_VERSION}-bin.zip" -OutFile ${env:TEMP}/apache-maven.zip ; `

maven/jdk17/Dockerfile.nanoserver

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,44 @@
11
# escape=`
2-
ARG JAVA_VERSION=17.0.10_7
32
ARG JAVA17_IMAGE_VERSION=3206.vb_15dcf73f6a_9-2
43
ARG PYTHON_VERSION=3.12.2
54

6-
FROM python:"${PYTHON_VERSION}"-windowsservercore-1809 AS python
5+
FROM python:"${PYTHON_VERSION}"-windowsservercore-1809 AS python-core
6+
7+
# ProgressPreference => Disable Progress bar for faster downloads
8+
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
79

810
# hadolint ignore=DL3013
911
RUN "C:/Python/python.exe" -m pip install --no-cache-dir --upgrade pip; `
1012
pip install --no-cache-dir setuptools wheel;
1113

12-
FROM eclipse-temurin:${JAVA_VERSION}-jdk-windowsservercore-1809 AS core
14+
# Adding jdk17 from Adoptium MSI installer (cannot only run msiexec.exe on ServerCore, NOT on nanoserver)
15+
ARG JAVA_VERSION=jdk-17.0.10+7
16+
RUN New-Item -ItemType Directory -Path C:\temp | Out-Null ; `
17+
$msiUrl = 'https://api.adoptium.net/v3/installer/version/{0}/windows/x64/jdk/hotspot/normal/eclipse?project=jdk' -f $env:JAVA_VERSION.Replace('+', '%2B') ; `
18+
Invoke-WebRequest $msiUrl -OutFile 'C:\temp\jdk.msi' ; `
19+
$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:\javaruntime' -Wait -Passthru ; `
20+
$proc.WaitForExit() ; `
21+
Remove-Item -Path C:\temp -Recurse | Out-Null
22+
1323
# Use inbound-agent's jdk17 only for running jenkins agent, not as default java
1424
FROM jenkins/inbound-agent:"${JAVA17_IMAGE_VERSION}"-jdk17-nanoserver-1809
1525

1626
# ProgressPreference => Disable Progress bar for faster downloads
1727
SHELL ["pwsh.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
1828

1929
# Adding python
20-
COPY --from=python C:/Python C:/tools/python
30+
COPY --from=python-core C:/Python C:/tools/python
2131

2232
# Install Launchable in this layer
2333
ARG LAUNCHABLE_VERSION=1.66.0
2434
RUN "C:/tools/python/python.exe" -m pip install --no-cache-dir launchable=="${env:LAUNCHABLE_VERSION}";
2535

26-
# Adding jdk17 from eclipse-temurin
27-
# Use ENV and not ARG : https://docs.docker.com/engine/reference/builder/#using-arg-variables
28-
ENV JAVA_HOME="C:\tools\jdk-17"
29-
COPY --from=core C:/openjdk-17 "${JAVA_HOME}"
36+
ENV JAVA_HOME="C:\tools\jdk-11"
37+
COPY --from=python-core C:/javaruntime $JAVA_HOME
3038

3139
# https://github.com/StefanScherer/dockerfiles-windows/tree/master/golang-issue-21867
32-
COPY --from=core C:/windows/system32/netapi32.dll C:/windows/system32/netapi32.dll
40+
COPY --from=python-core C:/windows/system32/netapi32.dll C:/windows/system32/netapi32.dll
41+
COPY --from=python-core C:/windows/system32/whoami.exe C:/windows/system32/whoami.exe
3342

3443
ARG MAVEN_VERSION=3.9.6
3544
RUN Invoke-WebRequest -Uri "https://archive.apache.org/dist/maven/maven-3/${env:MAVEN_VERSION}/binaries/apache-maven-${env:MAVEN_VERSION}-bin.zip" -OutFile ${env:TEMP}/apache-maven.zip ; `

maven/jdk21/Dockerfile.nanoserver

Lines changed: 22 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,50 @@
11
# escape=`
2-
ARG JAVA_VERSION=21-jdk
32
ARG JAVA17_IMAGE_VERSION=3206.vb_15dcf73f6a_9-2
43
ARG PYTHON_VERSION=3.12.2
54

6-
FROM python:"${PYTHON_VERSION}"-windowsservercore-1809 AS python
5+
FROM python:"${PYTHON_VERSION}"-windowsservercore-1809 AS python-core
6+
7+
# ProgressPreference => Disable Progress bar for faster downloads
8+
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
79

810
# hadolint ignore=DL3013
911
RUN "C:/Python/python.exe" -m pip install --no-cache-dir --upgrade pip; `
1012
pip install --no-cache-dir setuptools wheel;
1113

12-
## Comment out once temurin publishes an official JDK21 container image
13-
#FROM eclipse-temurin:${JAVA_VERSION}-jdk-windowsservercore-1809 AS core
14+
# Adding jdk21 from Adoptium installers
15+
ARG JAVA_VERSION=jdk-21+35
16+
RUN New-Item -ItemType Directory -Path C:\temp | Out-Null ; `
17+
$msiUrl = 'https://api.adoptium.net/v3/installer/version/{0}/windows/x64/jdk/hotspot/normal/eclipse?project=jdk' -f $env:JAVA_VERSION.Replace('+', '%2B') ; `
18+
Invoke-WebRequest $msiUrl -OutFile 'C:\temp\jdk.msi' ; `
19+
$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:\javaruntime' -Wait -Passthru ; `
20+
$proc.WaitForExit() ; `
21+
Remove-Item -Path C:\temp -Recurse | Out-Null
22+
1423
# Use inbound-agent's jdk17 only for running jenkins agent, not as default java
1524
FROM jenkins/inbound-agent:"${JAVA17_IMAGE_VERSION}"-jdk17-nanoserver-1809
1625

1726
# ProgressPreference => Disable Progress bar for faster downloads
1827
SHELL ["pwsh.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
1928

20-
ARG toolsDir="C:\tools"
21-
ARG pythonDir="$toolsDir\python"
22-
23-
ENV PYTHON_PATH="$pythonDir"
24-
ENV PATH="${pythonDir};${pythonDir}\Scripts;${PATH}"
25-
2629
# Adding python
27-
COPY --from=python C:/Python $pythonDir
30+
COPY --from=python-core C:/Python C:/tools/python
2831

2932
# Install Launchable in this layer
3033
ARG LAUNCHABLE_VERSION=1.66.0
31-
RUN python.exe -m pip install --no-cache-dir launchable=="${env:LAUNCHABLE_VERSION}";
32-
33-
# Retrieve jdk17 for running jenkins agent process but do not use it as default
34-
# Use ENV and not ARG : https://docs.docker.com/engine/reference/builder/#using-arg-variables
35-
ENV JAVA_HOME="$toolsDir\jdk-21"
36-
ENV PATH="${JAVA_HOME}\bin;${PATH}"
34+
RUN "C:/tools/python/python.exe" -m pip install --no-cache-dir launchable=="${env:LAUNCHABLE_VERSION}";
3735

38-
## Remove once temurin publishes an official JDK21 container image
39-
ARG jdk21Version="2023-08-09-06-56-beta"
40-
# From https://github.com/jenkins-infra/packer-images/blob/f02d850cb1ce74f4cf2a03af90a5ccd06925cb5c/provisioning/windows-provision.ps1#L126
41-
RUN $jdk21Url = 'https://github.com/adoptium/temurin21-binaries/releases/download/jdk21-{0}/OpenJDK21U-jdk_x64_windows_hotspot_{1}.zip' -f [System.Web.HTTPUtility]::UrlEncode($env:jdk21Version),$env:jdk21Version.Replace('-beta', ''); `
42-
Invoke-WebRequest -Uri "$jdk21Url" -OutFile "${env:TEMP}/temurin21.zip"; `
43-
Expand-Archive -Path "${env:TEMP}/temurin21.zip" -Destination "${env:toolsDir}" ; `
44-
Remove-Item ${env:TEMP}/temurin21.zip; `
45-
Move-Item -Path "${env:toolsDir}\jdk-21*" -Destination "${env:JAVA_HOME}";
46-
47-
## Comment out once temurin publishes an official JDK21 container image
48-
#COPY --from=core C:/openjdk-21 "${JAVA_HOME}"
36+
ENV JAVA_HOME="C:\tools\jdk-21"
37+
COPY --from=python-core C:/javaruntime $JAVA_HOME
4938

5039
# https://github.com/StefanScherer/dockerfiles-windows/tree/master/golang-issue-21867
51-
COPY --from=python C:/windows/system32/netapi32.dll C:/windows/system32/netapi32.dll
40+
COPY --from=python-core C:/windows/system32/netapi32.dll C:/windows/system32/netapi32.dll
41+
COPY --from=python-core C:/windows/system32/whoami.exe C:/windows/system32/whoami.exe
5242

5343
ARG MAVEN_VERSION=3.9.6
5444
RUN Invoke-WebRequest -Uri "https://archive.apache.org/dist/maven/maven-3/${env:MAVEN_VERSION}/binaries/apache-maven-${env:MAVEN_VERSION}-bin.zip" -OutFile ${env:TEMP}/apache-maven.zip ; `
5545
Expand-Archive -Path "${env:TEMP}/apache-maven.zip -Destination" C:/tools ; `
5646
Remove-Item ${env:TEMP}/apache-maven.zip ;
47+
48+
ENV PYTHON_PATH="C:\tools\python;C:\tools\python\Scripts"
5749
ENV MAVEN_HOME="C:\tools\apache-maven-${MAVEN_VERSION}"
58-
ENV PATH="${MAVEN_HOME}\bin;${PATH}"
50+
ENV PATH="${PYTHON_PATH};${JAVA_HOME}\bin;${PATH};${MAVEN_HOME}\bin;"

maven/jdk8/Dockerfile.nanoserver

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,46 @@
11
# escape=`
2-
ARG JAVA_VERSION=8u402-b06
32
ARG JAVA17_IMAGE_VERSION=3206.vb_15dcf73f6a_9-2
43
ARG PYTHON_VERSION=3.12.2
54

6-
FROM python:"${PYTHON_VERSION}"-windowsservercore-1809 AS python
5+
FROM python:"${PYTHON_VERSION}"-windowsservercore-1809 AS python-core
6+
7+
# ProgressPreference => Disable Progress bar for faster downloads
8+
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
79

810
# hadolint ignore=DL3013
911
RUN "C:/Python/python.exe" -m pip install --no-cache-dir --upgrade pip; `
1012
pip install --no-cache-dir setuptools wheel;
1113

12-
FROM eclipse-temurin:${JAVA_VERSION}-jdk-windowsservercore-1809 AS core
14+
# Adding jdk8 from Adoptium MSI installer (cannot only run msiexec.exe on ServerCore, NOT on nanoserver)
15+
# WARNING: JDK8 has a different URL pattern than the others (/jdk8<...>/ instead of /jdk-17<...>/)
16+
ARG JAVA_VERSION=jdk8u402-b06
17+
RUN New-Item -ItemType Directory -Path C:\temp | Out-Null ; `
18+
$msiUrl = 'https://api.adoptium.net/v3/installer/version/{0}/windows/x64/jdk/hotspot/normal/eclipse?project=jdk' -f $env:JAVA_VERSION.Replace('+', '%2B') ; `
19+
Invoke-WebRequest $msiUrl -OutFile 'C:\temp\jdk.msi' ; `
20+
$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:\javaruntime' -Wait -Passthru ; `
21+
$proc.WaitForExit() ; `
22+
Remove-Item -Path C:\temp -Recurse | Out-Null
23+
1324
# Use inbound-agent's jdk17 only for running jenkins agent, not as default java
1425
FROM jenkins/inbound-agent:${JAVA17_IMAGE_VERSION}-jdk17-nanoserver-1809
1526

1627
# ProgressPreference => Disable Progress bar for faster downloads
1728
SHELL ["pwsh.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
1829

1930
# Adding python
20-
COPY --from=python C:/Python C:/tools/python
31+
COPY --from=python-core C:/Python C:/tools/python
2132

2233
# Install Launchable in this layer
2334
ARG LAUNCHABLE_VERSION=1.66.0
2435
RUN "C:/tools/python/python.exe" -m pip install --no-cache-dir launchable=="${env:LAUNCHABLE_VERSION}";
2536

2637
# Adding jdk8 from eclipse-temurin
27-
# Use ENV and not ARG : https://docs.docker.com/engine/reference/builder/#using-arg-variables
2838
ENV JAVA_HOME="C:\tools\jdk-8"
29-
COPY --from=core C:/openjdk-8 "${JAVA_HOME}"
39+
COPY --from=python-core C:/javaruntime $JAVA_HOME
3040

3141
# https://github.com/StefanScherer/dockerfiles-windows/tree/master/golang-issue-21867
32-
COPY --from=core C:/windows/system32/netapi32.dll C:/windows/system32/netapi32.dll
42+
COPY --from=python-core C:/windows/system32/netapi32.dll C:/windows/system32/netapi32.dll
43+
COPY --from=python-core C:/windows/system32/whoami.exe C:/windows/system32/whoami.exe
3344

3445
ARG MAVEN_VERSION=3.9.6
3546
RUN Invoke-WebRequest -Uri "https://archive.apache.org/dist/maven/maven-3/${env:MAVEN_VERSION}/binaries/apache-maven-${env:MAVEN_VERSION}-bin.zip" -OutFile ${env:TEMP}/apache-maven.zip ; `

0 commit comments

Comments
 (0)