forked from jenkins-infra/docker-inbound-agents
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <damien.duportal@gmail.com>
- Loading branch information
Showing
4 changed files
with
76 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,50 @@ | ||
# escape=` | ||
ARG JAVA_VERSION=21-jdk | ||
ARG JAVA17_IMAGE_VERSION=3206.vb_15dcf73f6a_9-2 | ||
ARG PYTHON_VERSION=3.12.2 | ||
|
||
FROM python:"${PYTHON_VERSION}"-windowsservercore-1809 AS python | ||
FROM python:"${PYTHON_VERSION}"-windowsservercore-1809 AS python-core | ||
|
||
# ProgressPreference => Disable Progress bar for faster downloads | ||
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] | ||
|
||
# hadolint ignore=DL3013 | ||
RUN "C:/Python/python.exe" -m pip install --no-cache-dir --upgrade pip; ` | ||
pip install --no-cache-dir setuptools wheel; | ||
|
||
## Comment out once temurin publishes an official JDK21 container image | ||
#FROM eclipse-temurin:${JAVA_VERSION}-jdk-windowsservercore-1809 AS core | ||
# Adding jdk21 from Adoptium installers | ||
ARG JAVA_VERSION=jdk-21+35 | ||
RUN New-Item -ItemType Directory -Path C:\temp | Out-Null ; ` | ||
$msiUrl = 'https://api.adoptium.net/v3/installer/version/{0}/windows/x64/jdk/hotspot/normal/eclipse?project=jdk' -f $env:JAVA_VERSION.Replace('+', '%2B') ; ` | ||
Invoke-WebRequest $msiUrl -OutFile 'C:\temp\jdk.msi' ; ` | ||
$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 ; ` | ||
$proc.WaitForExit() ; ` | ||
Remove-Item -Path C:\temp -Recurse | Out-Null | ||
|
||
# Use inbound-agent's jdk17 only for running jenkins agent, not as default java | ||
FROM jenkins/inbound-agent:"${JAVA17_IMAGE_VERSION}"-jdk17-nanoserver-1809 | ||
|
||
# ProgressPreference => Disable Progress bar for faster downloads | ||
SHELL ["pwsh.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] | ||
|
||
ARG toolsDir="C:\tools" | ||
ARG pythonDir="$toolsDir\python" | ||
|
||
ENV PYTHON_PATH="$pythonDir" | ||
ENV PATH="${pythonDir};${pythonDir}\Scripts;${PATH}" | ||
|
||
# Adding python | ||
COPY --from=python C:/Python $pythonDir | ||
COPY --from=python-core C:/Python C:/tools/python | ||
|
||
# Install Launchable in this layer | ||
ARG LAUNCHABLE_VERSION=1.66.0 | ||
RUN python.exe -m pip install --no-cache-dir launchable=="${env:LAUNCHABLE_VERSION}"; | ||
|
||
# Retrieve jdk17 for running jenkins agent process but do not use it as default | ||
# Use ENV and not ARG : https://docs.docker.com/engine/reference/builder/#using-arg-variables | ||
ENV JAVA_HOME="$toolsDir\jdk-21" | ||
ENV PATH="${JAVA_HOME}\bin;${PATH}" | ||
RUN "C:/tools/python/python.exe" -m pip install --no-cache-dir launchable=="${env:LAUNCHABLE_VERSION}"; | ||
|
||
## Remove once temurin publishes an official JDK21 container image | ||
ARG jdk21Version="2023-08-09-06-56-beta" | ||
# From https://github.com/jenkins-infra/packer-images/blob/f02d850cb1ce74f4cf2a03af90a5ccd06925cb5c/provisioning/windows-provision.ps1#L126 | ||
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', ''); ` | ||
Invoke-WebRequest -Uri "$jdk21Url" -OutFile "${env:TEMP}/temurin21.zip"; ` | ||
Expand-Archive -Path "${env:TEMP}/temurin21.zip" -Destination "${env:toolsDir}" ; ` | ||
Remove-Item ${env:TEMP}/temurin21.zip; ` | ||
Move-Item -Path "${env:toolsDir}\jdk-21*" -Destination "${env:JAVA_HOME}"; | ||
|
||
## Comment out once temurin publishes an official JDK21 container image | ||
#COPY --from=core C:/openjdk-21 "${JAVA_HOME}" | ||
ENV JAVA_HOME="C:\tools\jdk-21" | ||
COPY --from=python-core C:/javaruntime $JAVA_HOME | ||
|
||
# https://github.com/StefanScherer/dockerfiles-windows/tree/master/golang-issue-21867 | ||
COPY --from=python C:/windows/system32/netapi32.dll C:/windows/system32/netapi32.dll | ||
COPY --from=python-core C:/windows/system32/netapi32.dll C:/windows/system32/netapi32.dll | ||
COPY --from=python-core C:/windows/system32/whoami.exe C:/windows/system32/whoami.exe | ||
|
||
ARG MAVEN_VERSION=3.9.6 | ||
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 ; ` | ||
Expand-Archive -Path "${env:TEMP}/apache-maven.zip -Destination" C:/tools ; ` | ||
Remove-Item ${env:TEMP}/apache-maven.zip ; | ||
|
||
ENV PYTHON_PATH="C:\tools\python;C:\tools\python\Scripts" | ||
ENV MAVEN_HOME="C:\tools\apache-maven-${MAVEN_VERSION}" | ||
ENV PATH="${MAVEN_HOME}\bin;${PATH}" | ||
ENV PATH="${PYTHON_PATH};${JAVA_HOME}\bin;${PATH};${MAVEN_HOME}\bin;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters