Skip to content

Commit

Permalink
WiP
Browse files Browse the repository at this point in the history
  • Loading branch information
dduportal committed Oct 12, 2021
1 parent f6045a5 commit a5f9c32
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 39 deletions.
28 changes: 18 additions & 10 deletions 11/windows/nanoserver-1809/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,24 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
ARG JAVA_VERSION="11.0.12_7"
FROM eclipse-temurin:${JAVA_VERSION}-jdk-windowsservercore-1809 AS core

FROM mcr.microsoft.com/windows/servercore:1809 AS core
# If you pass in a POWERSHELL_VERSION, make sure it ends with a hyphen, leaving it empty will
# use the 'latest'
ARG POWERSHELL_VERSION=
FROM mcr.microsoft.com/powershell:${POWERSHELL_VERSION}nanoserver-1809

FROM eclipse-temurin:11.0.12_7-jdk-nanoserver-1809
ARG JAVA_VERSION
ARG JAVA_HOME="C:\openjdk-11"

# The nanoserver image is nice and small, but we need a couple of things to get SSH working
COPY --from=core /windows/system32/netapi32.dll /windows/system32/netapi32.dll
COPY --from=core /windows/system32/whoami.exe /windows/system32/whoami.exe
COPY --from=core $JAVA_HOME $JAVA_HOME

SHELL ["pwsh.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ARG VERSION=4.10
LABEL Description="This is a base image, which provides the Jenkins agent executable (agent.jar)" Vendor="Jenkins project" Version="${VERSION}"
USER ContainerAdministrator

ARG GIT_VERSION=2.33.0
ARG GIT_PATCH_VERSION=2
Expand All @@ -51,10 +56,12 @@ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tl
Invoke-WebRequest $url -OutFile 'GitLfs.zip' -UseBasicParsing ; `
Expand-Archive GitLfs.zip -DestinationPath c:\mingit\mingw64\bin ; `
Remove-Item GitLfs.zip -Force ; `
& C:\mingit\cmd\git.exe lfs install ; `
$CurrentPath = (Get-Itemproperty -path 'hklm:\system\currentcontrolset\control\session manager\environment' -Name Path).Path ; `
$NewPath = $CurrentPath + ';C:\mingit\cmd' ; `
Set-ItemProperty -path 'hklm:\system\currentcontrolset\control\session manager\environment' -Name Path -Value $NewPath
& C:\mingit\cmd\git.exe lfs install

ENV ProgramFiles="C:\Program Files" `
WindowsPATH="C:\Windows\system32;C:\Windows" `
JAVA_HOME="C:\openjdk-11"
ENV PATH="${WindowsPATH};${ProgramFiles}\PowerShell;${JAVA_HOME}\bin;C:\mingit\cmd"

ARG user=jenkins

Expand All @@ -64,7 +71,6 @@ ARG AGENT_HASH_FILENAME=$AGENT_FILENAME.sha1
RUN net accounts /maxpwage:unlimited ; `
net user "$env:user" /add /expire:never /passwordreq:no ; `
net localgroup Administrators /add $env:user ; `
Set-LocalUser -Name $env:user -PasswordNeverExpires 1; `
New-Item -ItemType Directory -Path C:/ProgramData/Jenkins | Out-Null

ARG AGENT_ROOT=C:/Users/$user
Expand All @@ -73,6 +79,8 @@ ARG AGENT_WORKDIR=${AGENT_ROOT}/Work
ENV AGENT_WORKDIR=${AGENT_WORKDIR}

# Get the Agent from the Jenkins Artifacts Repository
ARG VERSION=4.10
LABEL Description="This is a base image, which provides the Jenkins agent executable (agent.jar)" Vendor="Jenkins project" Version="${VERSION}"
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest $('https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/{0}/remoting-{0}.jar' -f $env:VERSION) -OutFile $(Join-Path C:/ProgramData/Jenkins $env:AGENT_FILENAME) -UseBasicParsing ; `
Invoke-WebRequest $('https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/{0}/remoting-{0}.jar.sha1' -f $env:VERSION) -OutFile (Join-Path C:/ProgramData/Jenkins $env:AGENT_HASH_FILENAME) -UseBasicParsing ; `
Expand Down
5 changes: 2 additions & 3 deletions 11/windows/windowsservercore-ltsc2019/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ FROM eclipse-temurin:11.0.12_7-jdk-windowsservercore-1809

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ARG VERSION=4.10
LABEL Description="This is a base image, which provides the Jenkins agent executable (agent.jar)" Vendor="Jenkins project" Version="${VERSION}"

ARG GIT_VERSION=2.33.0
ARG GIT_PATCH_VERSION=2
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Expand Down Expand Up @@ -67,6 +64,8 @@ ARG AGENT_WORKDIR=${AGENT_ROOT}/Work
ENV AGENT_WORKDIR=${AGENT_WORKDIR}

# Get the Agent from the Jenkins Artifacts Repository
ARG VERSION=4.10
LABEL Description="This is a base image, which provides the Jenkins agent executable (agent.jar)" Vendor="Jenkins project" Version="${VERSION}"
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest $('https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/{0}/remoting-{0}.jar' -f $env:VERSION) -OutFile $(Join-Path C:/ProgramData/Jenkins $env:AGENT_FILENAME) -UseBasicParsing ; `
Invoke-WebRequest $('https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/{0}/remoting-{0}.jar.sha1' -f $env:VERSION) -OutFile (Join-Path C:/ProgramData/Jenkins $env:AGENT_HASH_FILENAME) -UseBasicParsing ; `
Expand Down
28 changes: 18 additions & 10 deletions 17/windows/nanoserver-1809/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,24 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
ARG JAVA_VERSION="17_35"
FROM eclipse-temurin:${JAVA_VERSION}-jdk-windowsservercore-1809 AS core

FROM mcr.microsoft.com/windows/servercore:1809 AS core
# If you pass in a POWERSHELL_VERSION, make sure it ends with a hyphen, leaving it empty will
# use the 'latest'
ARG POWERSHELL_VERSION=
FROM mcr.microsoft.com/powershell:${POWERSHELL_VERSION}nanoserver-1809

FROM eclipse-temurin:17_35-jdk-nanoserver-1809
ARG JAVA_VERSION
ARG JAVA_HOME="C:\openjdk-17"

# The nanoserver image is nice and small, but we need a couple of things to get SSH working
COPY --from=core /windows/system32/netapi32.dll /windows/system32/netapi32.dll
COPY --from=core /windows/system32/whoami.exe /windows/system32/whoami.exe
COPY --from=core $JAVA_HOME $JAVA_HOME

SHELL ["pwsh.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ARG VERSION=4.10
LABEL Description="This is a base image, which provides the Jenkins agent executable (agent.jar)" Vendor="Jenkins project" Version="${VERSION}"
USER ContainerAdministrator

ARG GIT_VERSION=2.33.0
ARG GIT_PATCH_VERSION=2
Expand All @@ -51,10 +56,12 @@ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tl
Invoke-WebRequest $url -OutFile 'GitLfs.zip' -UseBasicParsing ; `
Expand-Archive GitLfs.zip -DestinationPath c:\mingit\mingw64\bin ; `
Remove-Item GitLfs.zip -Force ; `
& C:\mingit\cmd\git.exe lfs install ; `
$CurrentPath = (Get-Itemproperty -path 'hklm:\system\currentcontrolset\control\session manager\environment' -Name Path).Path ; `
$NewPath = $CurrentPath + ';C:\mingit\cmd' ; `
Set-ItemProperty -path 'hklm:\system\currentcontrolset\control\session manager\environment' -Name Path -Value $NewPath
& C:\mingit\cmd\git.exe lfs install

ENV ProgramFiles="C:\Program Files" `
WindowsPATH="C:\Windows\system32;C:\Windows" `
JAVA_HOME="C:\openjdk-11"
ENV PATH="${WindowsPATH};${ProgramFiles}\PowerShell;${JAVA_HOME}\bin;C:\mingit\cmd"

ARG user=jenkins

Expand All @@ -64,7 +71,6 @@ ARG AGENT_HASH_FILENAME=$AGENT_FILENAME.sha1
RUN net accounts /maxpwage:unlimited ; `
net user "$env:user" /add /expire:never /passwordreq:no ; `
net localgroup Administrators /add $env:user ; `
Set-LocalUser -Name $env:user -PasswordNeverExpires 1; `
New-Item -ItemType Directory -Path C:/ProgramData/Jenkins | Out-Null

ARG AGENT_ROOT=C:/Users/$user
Expand All @@ -73,6 +79,8 @@ ARG AGENT_WORKDIR=${AGENT_ROOT}/Work
ENV AGENT_WORKDIR=${AGENT_WORKDIR}

# Get the Agent from the Jenkins Artifacts Repository
ARG VERSION=4.10
LABEL Description="This is a base image, which provides the Jenkins agent executable (agent.jar)" Vendor="Jenkins project" Version="${VERSION}"
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest $('https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/{0}/remoting-{0}.jar' -f $env:VERSION) -OutFile $(Join-Path C:/ProgramData/Jenkins $env:AGENT_FILENAME) -UseBasicParsing ; `
Invoke-WebRequest $('https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/{0}/remoting-{0}.jar.sha1' -f $env:VERSION) -OutFile (Join-Path C:/ProgramData/Jenkins $env:AGENT_HASH_FILENAME) -UseBasicParsing ; `
Expand Down
5 changes: 2 additions & 3 deletions 17/windows/windowsservercore-ltsc2019/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ FROM eclipse-temurin:17_35-jdk-windowsservercore-1809

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ARG VERSION=4.10
LABEL Description="This is a base image, which provides the Jenkins agent executable (agent.jar)" Vendor="Jenkins project" Version="${VERSION}"

ARG GIT_VERSION=2.33.0
ARG GIT_PATCH_VERSION=2
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Expand Down Expand Up @@ -67,6 +64,8 @@ ARG AGENT_WORKDIR=${AGENT_ROOT}/Work
ENV AGENT_WORKDIR=${AGENT_WORKDIR}

# Get the Agent from the Jenkins Artifacts Repository
ARG VERSION=4.10
LABEL Description="This is a base image, which provides the Jenkins agent executable (agent.jar)" Vendor="Jenkins project" Version="${VERSION}"
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest $('https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/{0}/remoting-{0}.jar' -f $env:VERSION) -OutFile $(Join-Path C:/ProgramData/Jenkins $env:AGENT_FILENAME) -UseBasicParsing ; `
Invoke-WebRequest $('https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/{0}/remoting-{0}.jar.sha1' -f $env:VERSION) -OutFile (Join-Path C:/ProgramData/Jenkins $env:AGENT_HASH_FILENAME) -UseBasicParsing ; `
Expand Down
29 changes: 19 additions & 10 deletions 8/windows/nanoserver-1809/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,24 @@
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
ARG JAVA_VERSION="8u302-b08"
FROM eclipse-temurin:${JAVA_VERSION}-jdk-windowsservercore-1809 AS core

FROM mcr.microsoft.com/windows/servercore:1809 AS core
# If you pass in a POWERSHELL_VERSION, make sure it ends with a hyphen, leaving it empty will
# use the 'latest'
ARG POWERSHELL_VERSION=
FROM mcr.microsoft.com/powershell:${POWERSHELL_VERSION}nanoserver-1809

FROM eclipse-temurin:8u302-b08-jdk-nanoserver-1809
ARG JAVA_VERSION
ARG JAVA_HOME="C:\openjdk-8"

# The nanoserver image is nice and small, but we need a couple of things to get SSH working
COPY --from=core /windows/system32/netapi32.dll /windows/system32/netapi32.dll
COPY --from=core /windows/system32/whoami.exe /windows/system32/whoami.exe
COPY --from=core $JAVA_HOME $JAVA_HOME

SHELL ["pwsh.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ARG VERSION=4.10
LABEL Description="This is a base image, which provides the Jenkins agent executable (agent.jar)" Vendor="Jenkins project" Version="${VERSION}"
USER ContainerAdministrator

ARG GIT_VERSION=2.33.0
ARG GIT_PATCH_VERSION=2
Expand All @@ -51,10 +56,12 @@ RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tl
Invoke-WebRequest $url -OutFile 'GitLfs.zip' -UseBasicParsing ; `
Expand-Archive GitLfs.zip -DestinationPath c:\mingit\mingw64\bin ; `
Remove-Item GitLfs.zip -Force ; `
& C:\mingit\cmd\git.exe lfs install ; `
$CurrentPath = (Get-Itemproperty -path 'hklm:\system\currentcontrolset\control\session manager\environment' -Name Path).Path ; `
$NewPath = $CurrentPath + ';C:\mingit\cmd' ; `
Set-ItemProperty -path 'hklm:\system\currentcontrolset\control\session manager\environment' -Name Path -Value $NewPath
& C:\mingit\cmd\git.exe lfs install

ENV ProgramFiles="C:\Program Files" `
WindowsPATH="C:\Windows\system32;C:\Windows" `
JAVA_HOME="C:\openjdk-11"
ENV PATH="${WindowsPATH};${ProgramFiles}\PowerShell;${JAVA_HOME}\bin;C:\mingit\cmd"

ARG user=jenkins

Expand All @@ -64,7 +71,6 @@ ARG AGENT_HASH_FILENAME=$AGENT_FILENAME.sha1
RUN net accounts /maxpwage:unlimited ; `
net user "$env:user" /add /expire:never /passwordreq:no ; `
net localgroup Administrators /add $env:user ; `
Set-LocalUser -Name $env:user -PasswordNeverExpires 1; `
New-Item -ItemType Directory -Path C:/ProgramData/Jenkins | Out-Null

ARG AGENT_ROOT=C:/Users/$user
Expand All @@ -73,6 +79,9 @@ ARG AGENT_WORKDIR=${AGENT_ROOT}/Work
ENV AGENT_WORKDIR=${AGENT_WORKDIR}

# Get the Agent from the Jenkins Artifacts Repository
ARG VERSION=4.10
LABEL Description="This is a base image, which provides the Jenkins agent executable (agent.jar)" Vendor="Jenkins project" Version="${VERSION}"
RUN echo $('https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/{0}/remoting-{0}.jar' -f $env:VERSION)
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest $('https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/{0}/remoting-{0}.jar' -f $env:VERSION) -OutFile $(Join-Path C:/ProgramData/Jenkins $env:AGENT_FILENAME) -UseBasicParsing ; `
Invoke-WebRequest $('https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/{0}/remoting-{0}.jar.sha1' -f $env:VERSION) -OutFile (Join-Path C:/ProgramData/Jenkins $env:AGENT_HASH_FILENAME) -UseBasicParsing ; `
Expand Down
5 changes: 2 additions & 3 deletions 8/windows/windowsservercore-ltsc2019/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ FROM eclipse-temurin:8u302-b08-jdk-windowsservercore-1809

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

ARG VERSION=4.10
LABEL Description="This is a base image, which provides the Jenkins agent executable (agent.jar)" Vendor="Jenkins project" Version="${VERSION}"

ARG GIT_VERSION=2.33.0
ARG GIT_PATCH_VERSION=2
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Expand Down Expand Up @@ -67,6 +64,8 @@ ARG AGENT_WORKDIR=${AGENT_ROOT}/Work
ENV AGENT_WORKDIR=${AGENT_WORKDIR}

# Get the Agent from the Jenkins Artifacts Repository
ARG VERSION=4.10
LABEL Description="This is a base image, which provides the Jenkins agent executable (agent.jar)" Vendor="Jenkins project" Version="${VERSION}"
RUN [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; `
Invoke-WebRequest $('https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/{0}/remoting-{0}.jar' -f $env:VERSION) -OutFile $(Join-Path C:/ProgramData/Jenkins $env:AGENT_FILENAME) -UseBasicParsing ; `
Invoke-WebRequest $('https://repo.jenkins-ci.org/public/org/jenkins-ci/main/remoting/{0}/remoting-{0}.jar.sha1' -f $env:VERSION) -OutFile (Join-Path C:/ProgramData/Jenkins $env:AGENT_HASH_FILENAME) -UseBasicParsing ; `
Expand Down
33 changes: 33 additions & 0 deletions build-windows.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
version: '3'

services:
jdk8-nanoserver:
build:
context: ./8/windows/nanoserver-1809/
args:
- VERSION=$REMOTING_VERSION
jdk11-nanoserver:
build:
context: ./11/windows/nanoserver-1809/
args:
- VERSION=$REMOTING_VERSION
jdk17-nanoserver:
build:
context: ./17/windows/nanoserver-1809/
args:
- VERSION=$REMOTING_VERSION
jdk8-windowsservercore:
build:
context: ./8/windows/windowsservercore-ltsc2019/
args:
- VERSION=$REMOTING_VERSION
jdk11-windowsservercore:
build:
context: ./11/windows/windowsservercore-ltsc2019/
args:
- VERSION=$REMOTING_VERSION
jdk17-windowsservercore:
build:
context: ./17/windows/windowsservercore-ltsc2019/
args:
- VERSION=$REMOTING_VERSION
12 changes: 12 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ if(![String]::IsNullOrWhiteSpace($env:REMOTING_VERSION)) {
# this is the jdk version that will be used for the 'bare tag' images, e.g., jdk8-windowsservercore-1809 -> windowsserver-1809
$defaultBuild = '8'
$builds = @{}
$env:REMOTING_VERSION = "$RemotingVersion-$BuildNumber"
$ProgressPreference = 'SilentlyContinue' # Disable Progress bar for faster downloads
Set-PSDebug -Trace 1

# Install docker-compose v2
$dockerComposeBin = "C:\tools\docker-compose.exe"
Invoke-WebRequest "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Windows-x86_64.exe" -OutFile "$dockerComposeBin"
& "$dockerComposeBin" --version
& "$dockerComposeBin" --file=build-windows.yaml build
Exit 1

Get-ChildItem -Recurse -Include windows -Directory | ForEach-Object {
Get-ChildItem -Directory -Path $_ | Where-Object { Test-Path (Join-Path $_.FullName "Dockerfile") } | ForEach-Object {
Expand Down Expand Up @@ -76,6 +86,8 @@ if(![System.String]::IsNullOrWhiteSpace($Build) -and $builds.ContainsKey($Build)
}
}
} else {
# Prebuild in parallel all images to populate the cache

foreach($b in $builds.Keys) {
foreach($tag in $builds[$b]['Tags']) {
Write-Host "Building $b => tag=$tag"
Expand Down

0 comments on commit a5f9c32

Please sign in to comment.