Skip to content

Commit

Permalink
Add Windows 2025 variant
Browse files Browse the repository at this point in the history
We dont have AWS ECS runners to use these on yet, but let's prepare
  • Loading branch information
chadlwilson committed Jan 19, 2025
1 parent 88b7ee9 commit 571013f
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 2 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,31 @@ jobs:
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

windows-2025:
runs-on: windows-2025
steps:
- uses: actions/checkout@v4

- name: Verify a tag is present
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; }

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
flavor: |
latest=false
prefix=windows2025-
- name: Build and push
id: build
uses: mr-smithers-excellent/docker-build-push@v6
with:
dockerfile: windowsservercore-2025.Dockerfile
image: ${{ env.REGISTRY_IMAGE }}
tags: ${{ steps.meta.outputs.version }}
registry: docker.io
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
2 changes: 1 addition & 1 deletion provision/provision.ps1 → provision/provision-choco.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Write-Host "Installing packages..."
&"$PSScriptroot\provision-install-packages.ps1"
&"$PSScriptroot\provision-install-packages-choco.ps1"
Write-Host "Initializing Gradle cache for gocd..."
&"$PSScriptroot\provision-init-gradle-cache.ps1"
Write-Host "Completed provisioning (layer now exporting...)"
File renamed without changes.
76 changes: 76 additions & 0 deletions provision/provision-install-packages-winget.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
$JAVA_VERSION='21.0.5.11'
$NODEJS_VERSION='22.13.0'
$RUBY_VERSION='3.4.1.1'

$GOLANG_BOOTSTRAPPER_VERSION='2.23'
$P4D_VERSION='24.1'

# Copy over configs
New-Item "${env:USERPROFILE}\.gradle" -ItemType Directory | Out-Null
New-Item "${env:USERPROFILE}\.m2" -ItemType Directory | Out-Null
New-Item "${env:USERPROFILE}\.bundle" -ItemType Directory | Out-Null

Copy-Item "$PSScriptroot\bundle-config" "${env:USERPROFILE}\.bundle\config"
Copy-Item "$PSScriptroot\gitconfig-windows" "${env:USERPROFILE}\.gitconfig"
Copy-Item "$PSScriptroot\init.gradle" "${env:USERPROFILE}\.gradle\init.gradle"
Copy-Item "$PSScriptroot\npmrc" "${env:USERPROFILE}\.npmrc"
Copy-Item "$PSScriptroot\settings.xml" "${env:USERPROFILE}\.m2\settings.xml"

function PrefixToSystemAndCurrentPath {
param (
[Parameter(Mandatory=$true)]
[string]$PathPrefix
)
$newSystemPath = "$PathPrefix;" + [System.Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::Machine)
$env:Path = $newSystemPath + ";" + [System.Environment]::GetEnvironmentVariable("Path", [EnvironmentVariableTarget]::User)
[Environment]::SetEnvironmentVariable("Path", $newSystemPath, [EnvironmentVariableTarget]::Machine)
}

# install chocolatey
$chocolateyUseWindowsCompression = 'true'
$env:chocolateyUseWindowsCompression = 'true'
$ErrorActionPreference = "Stop"
$progressPreference = 'silentlyContinue'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

$env:ChocolateyInstall = Convert-Path "$((Get-Command choco).path)\..\.."
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
RefreshEnv

# install packages
choco install --no-progress -y nodejs --version="${NODEJS_VERSION}"
RefreshEnv
corepack enable
yarn --version

choco install --no-progress -y temurin --version="${JAVA_VERSION}"
choco install --no-progress -y git --params "/NoAutoCrlf"
choco install --no-progress -y nant ant hg sliksvn gnupg awscli
choco install --no-progress -y --ignore-checksums p4 # Ignore checksums due to package not using repeatable build links to downloads
choco install --no-progress -y windows-sdk-11-version-22h2-all --install-arguments='/features OptionId.SigningTools /ceip off'
choco install --no-progress -y --ignore-checksums googlechrome # Ignore checksums due to package not using repeatable build links to downloads

choco install --no-progress -y ruby --version="${RUBY_VERSION}"
# Install MSYS2 and dev toolchain for compiling certain native Ruby extensions, introduced for google-protobuf 3.25.0+
# Following pattern at https://community.chocolatey.org/packages/msys2#description
$msysInstallDir = "C:\tools\msys64"
choco install --no-progress -y msys2 --params "/NoUpdate /InstallDir:${msysInstallDir}"
RefreshEnv
PrefixToSystemAndCurrentPath("${msysInstallDir}\ucrt64\bin;${msysInstallDir}\usr\bin") # Manually add MSYS2 and tools to path to avoid having to do shell-specific "ridk enable" in builds.
ridk install 2 3 # Update packages and install development toolchain

# Remove chocolatey from temp location
Remove-Item C:\\Users\\ContainerAdministrator\\AppData\\Local\\Temp\\chocolatey -Force -Recurse | Out-Null

# install p4d / helix-core-server
New-Item "${env:ProgramFiles}\\Perforce\\bin\\" -ItemType Directory | Out-Null
Invoke-WebRequest https://cdist2.perforce.com/perforce/r$P4D_VERSION/bin.ntx64/p4d.exe -Outfile "${env:ProgramFiles}\\Perforce\\bin\\p4d.exe"
PrefixToSystemAndCurrentPath("${env:ProgramFiles}\\Perforce\\bin")

# install gocd bootstrapper
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

Add-LocalGroupMember -Group "Administrators" -Member "ContainerAdministrator"
5 changes: 5 additions & 0 deletions provision/provision-winget.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Write-Host "Installing packages..."
&"$PSScriptroot\provision-install-packages-winget.ps1"
Write-Host "Initializing Gradle cache for gocd..."
&"$PSScriptroot\provision-init-gradle-cache.ps1"
Write-Host "Completed provisioning (layer now exporting...)"
20 changes: 20 additions & 0 deletions windowsservercore-2025.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mcr.microsoft.com/windows/servercore:ltsc2025
LABEL org.opencontainers.image.authors="GoCD Team <go-cd-dev@googlegroups.com>"

# Shamelessly nabbed from https://github.com/gantrior/docker-chrome-windows
#
# Fonts are needed for Chrome to launch and function. Windows Server Core
# does not include fonts, so we need to install them ourselves.
ADD Files/FontsToAdd.tar /Fonts/
WORKDIR /Fonts/
RUN powershell -File .\\Add-Font.ps1 Fonts
WORKDIR /

ENV TMP=C:\\tmp \
TEMP=C:\\tmp

COPY provision C:\\Users\\ContainerAdministrator\\provision

RUN powershell -File C:\\Users\\ContainerAdministrator\\provision\\provision-winget.ps1

CMD ["C:\\go-agent.exe"]
2 changes: 1 addition & 1 deletion windowsservercore.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ ENV TMP=C:\\tmp \

COPY provision C:\\Users\\ContainerAdministrator\\provision

RUN powershell -File C:\\Users\\ContainerAdministrator\\provision\\provision.ps1
RUN powershell -File C:\\Users\\ContainerAdministrator\\provision\\provision-choco.ps1

CMD ["C:\\go-agent.exe"]

0 comments on commit 571013f

Please sign in to comment.