Skip to content

Commit ac3ad28

Browse files
committed
Add docker-init like in jenkinsci/docker-ssh-agent#581 (which doesn't fail on wsc2022 image builds from wsc2025 agent)
1 parent ee21b51 commit ac3ad28

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

Jenkinsfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,17 @@ stage('Build') {
5757
}
5858

5959
withEnv(["IMAGE_TYPE=${imageType}"]) {
60+
stage('Prepare Docker') {
61+
infra.withDockerCredentials {
62+
powershell './make.ps1 -Target docker-init'
63+
}
64+
}
6065
if (!infra.isTrusted()) {
6166
/* Outside of the trusted.ci environment, we're building and testing
6267
* the Dockerfile in this repository, but not publishing to docker hub
6368
*/
6469
stage("Build ${imageType}") {
6570
infra.withDockerCredentials {
66-
powershell 'docker info'
6771
powershell './make.ps1 build'
6872
}
6973
}

make.ps1

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,30 @@ $env:COMMIT_SHA=$(git rev-parse HEAD)
6262
$baseDockerCmd = 'docker-compose --file=build-windows.yaml'
6363
$baseDockerBuildCmd = '{0} build --parallel --pull' -f $baseDockerCmd
6464

65+
function Initialize-Docker() {
66+
# Cf https://github.com/jenkins-infra/jenkins-infra/blob/production/modules/profile/templates/jenkinscontroller/casc/clouds-ec2.yaml.erb
67+
$dockerDaemonConfigPath = 'C:\ProgramData\Docker\config\daemon.json'
68+
if (Test-Path $dockerDaemonConfigPath) {
69+
$dockerDaemonConfig = Get-Content -Path $dockerDaemonConfigPath -Raw | ConvertFrom-Json
70+
Write-Host "${dockerDaemonConfigPath} file content:"
71+
$dockerDaemonConfig | ConvertTo-Json
72+
# Remove docker daemon config setting "data-root" to Z:\docker (NVMe mount) to avoid hitting moby/moby#48093
73+
Remove-Item -Path $dockerDaemonConfigPath
74+
Restart-Service docker
75+
}
76+
Get-ComputerInfo | Select-Object OsName, OsBuildNumber, WindowsVersion
77+
Get-WindowsFeature Containers | Out-String
78+
Invoke-Expression 'docker info'
79+
Get-CimInstance -ClassName Win32_Processor
80+
Get-ChildItem env: | Select-Object Name, Value
81+
}
82+
83+
if($target -eq 'docker-init') {
84+
Write-Host '= Initialize-Docker then exit'
85+
Initialize-Docker
86+
exit 0
87+
}
88+
6589
Write-Host "= PREPARE: List of $Organisation/$Repository images and tags to be processed:"
6690
Invoke-Expression "$baseDockerCmd config"
6791

0 commit comments

Comments
 (0)