Skip to content

Commit 1ebd701

Browse files
committed
Introduce Windows 2025 / winget image builds
1 parent 7e08668 commit 1ebd701

File tree

4 files changed

+131
-0
lines changed

4 files changed

+131
-0
lines changed

.github/workflows/docker-publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,38 @@ jobs:
167167
username: ${{ secrets.DOCKERHUB_USERNAME }}
168168
password: ${{ secrets.DOCKERHUB_TOKEN }}
169169
pushImage: ${{ github.event_name != 'pull_request' }}
170+
171+
windows-2025:
172+
runs-on: windows-2025
173+
steps:
174+
- name: Harden the runner (Audit all outbound calls)
175+
uses: step-security/harden-runner@0634a2670c59f64b4a01f0f96f84700a4088b9f0 # v2.12.0
176+
with:
177+
egress-policy: audit
178+
179+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
180+
181+
- name: Verify a tag is present
182+
if: ${{ github.event_name != 'pull_request' }}
183+
run: if ($(git tag --points-at HEAD --sort=version:refname | tail -n1).length -eq 0) { echo "Please set a tag pointing to the HEAD"; exit 1; }
184+
185+
- name: Docker meta
186+
id: meta
187+
uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0
188+
with:
189+
images: ${{ env.REGISTRY_IMAGE }}
190+
flavor: |
191+
latest=false
192+
prefix=windows2025-
193+
194+
- name: Build and push
195+
id: build
196+
uses: mr-smithers-excellent/docker-build-push@59523c638baec979a74fea99caa9e29d97e5963c # v6.4
197+
with:
198+
dockerfile: windowsservercore-2025.Dockerfile
199+
image: ${{ env.REGISTRY_IMAGE }}
200+
tags: ${{ steps.meta.outputs.version }}
201+
registry: docker.io
202+
username: ${{ secrets.DOCKERHUB_USERNAME }}
203+
password: ${{ secrets.DOCKERHUB_TOKEN }}
204+
pushImage: ${{ github.event_name != 'pull_request' }}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
$JAVA_VERSION='21.0.6.7'
2+
$NODEJS_VERSION='22.16.0'
3+
4+
$GOLANG_BOOTSTRAPPER_VERSION='2.29'
5+
$P4_VERSION='25.1'
6+
$ANT_VERSION='1.10.15'
7+
$NANT_VERSION='0.92'
8+
9+
# Copy over configs
10+
New-Item "${env:USERPROFILE}\.gradle" -ItemType Directory | Out-Null
11+
New-Item "${env:USERPROFILE}\.m2" -ItemType Directory | Out-Null
12+
New-Item "${env:USERPROFILE}\.bundle" -ItemType Directory | Out-Null
13+
14+
Copy-Item "$PSScriptroot\bundle-config" "${env:USERPROFILE}\.bundle\config"
15+
Copy-Item "$PSScriptroot\gitconfig-windows" "${env:USERPROFILE}\.gitconfig"
16+
Copy-Item "$PSScriptroot\init.gradle" "${env:USERPROFILE}\.gradle\init.gradle"
17+
Copy-Item "$PSScriptroot\npmrc" "${env:USERPROFILE}\.npmrc"
18+
Copy-Item "$PSScriptroot\settings.xml" "${env:USERPROFILE}\.m2\settings.xml"
19+
20+
function Winget-Install {
21+
winget install --accept-source-agreements --accept-package-agreements --disable-interactivity @args
22+
}
23+
24+
function PrefixToSystemAndCurrentPath {
25+
param (
26+
[Parameter(Mandatory=$true)]
27+
[string]$PathPrefix
28+
)
29+
$newSystemPath = "$PathPrefix;" + [System.Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine)
30+
$env:Path = $newSystemPath + ";" + [System.Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::User)
31+
[Environment]::SetEnvironmentVariable("Path", $newSystemPath, [EnvironmentVariableTarget]::Machine)
32+
}
33+
34+
# install winget
35+
Get-WindowsOptionalFeature -Online | ? FeatureName -like *winget*
36+
37+
# install packages
38+
Winget-Install OpenJS.NodeJS.LTS --version="${NODEJS_VERSION}"
39+
corepack enable
40+
yarn --version
41+
42+
Winget-Install EclipseAdoptium.Temurin.21.JDK --version="${JAVA_VERSION}"
43+
44+
Winget-Install Git.Git Mercurial.Mercurial Slik.Subversion Google.Chrome
45+
git config --global core.autocrlf false
46+
47+
Winget-Install RubyInstallerTeam.RubyWithDevKit.3.2
48+
ridk install 2 3 # Update packages and install development toolchain
49+
50+
# install p4 client and p4d / helix-core-server
51+
New-Item "${env:ProgramFiles}\\Perforce\\bin\\" -ItemType Directory | Out-Null
52+
PrefixToSystemAndCurrentPath("${env:ProgramFiles}\\Perforce\\bin")
53+
Invoke-WebRequest https://cdist2.perforce.com/perforce/r$P4_VERSION/bin.ntx64/p4.exe -Outfile "${env:ProgramFiles}\\Perforce\\bin\\p4.exe"
54+
Invoke-WebRequest https://cdist2.perforce.com/perforce/r$P4_VERSION/bin.ntx64/p4d.exe -Outfile "${env:ProgramFiles}\\Perforce\\bin\\p4d.exe"
55+
56+
# Install ant
57+
Invoke-WebRequest https://dlcdn.apache.org//ant/binaries/apache-ant-${ANT_VERSION}-bin.zip -Outfile "${env:TEMP}\\ant.zip"
58+
Expand-Archive -Path "${env:TEMP}\\ant.zip" -DestinationPath "C:\\tools"
59+
PrefixToSystemAndCurrentPath("C:\\tools\\apache-ant-${ANT_VERSION}\\bin")
60+
Remove-Item "${env:TEMP}\\ant.zip" -Force
61+
62+
# Install nant
63+
Invoke-WebRequest https://onboardcloud.dl.sourceforge.net/project/nant/nant/${NANT_VERSION}/nant-${NANT_VERSION}-bin.zip?viasf=1 -Outfile "${env:TEMP}\\nant.zip"
64+
Expand-Archive -Path "${env:TEMP}\\nant.zip" -DestinationPath "C:\\tools"
65+
PrefixToSystemAndCurrentPath("C:\\tools\\nant-${NANT_VERSION}\\bin")
66+
Remove-Item "${env:TEMP}\\nant.zip" -Force
67+
68+
# install gocd bootstrapper
69+
Invoke-WebRequest https://github.com/gocd-contrib/gocd-golang-bootstrapper/releases/download/${GOLANG_BOOTSTRAPPER_VERSION}/go-bootstrapper-${GOLANG_BOOTSTRAPPER_VERSION}.windows.amd64.exe -Outfile C:\\go-agent.exe
70+
71+
Add-LocalGroupMember -Group "Administrators" -Member "ContainerAdministrator"

provision/provision-winget.ps1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Write-Host "Installing packages..."
2+
&"$PSScriptroot\provision-install-packages-winget.ps1"
3+
Write-Host "Initializing Gradle cache for gocd..."
4+
&"$PSScriptroot\provision-init-gradle-cache.ps1"
5+
Write-Host "Completed provisioning (layer now exporting...)"

windowsservercore-2025.Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM mcr.microsoft.com/windows/servercore:ltsc2025
2+
LABEL org.opencontainers.image.authors="GoCD Team <[email protected]>"
3+
4+
# Shamelessly nabbed from https://github.com/gantrior/docker-chrome-windows
5+
#
6+
# Fonts are needed for Chrome to launch and function. Windows Server Core
7+
# does not include fonts, so we need to install them ourselves.
8+
ADD Files/FontsToAdd.tar /Fonts/
9+
WORKDIR /Fonts/
10+
RUN powershell -File .\\Add-Font.ps1 Fonts
11+
WORKDIR /
12+
13+
ENV TMP=C:\\tmp \
14+
TEMP=C:\\tmp
15+
16+
COPY provision C:\\Users\\ContainerAdministrator\\provision
17+
18+
RUN powershell -File C:\\Users\\ContainerAdministrator\\provision\\provision-winget.ps1
19+
20+
CMD ["C:\\go-agent.exe"]

0 commit comments

Comments
 (0)