1
0
Fork 0

tweaks for docker on windows

This commit is contained in:
Christian Kühnel 2019-12-18 17:29:21 +00:00
parent 906a7fccee
commit 451671cd88
4 changed files with 70 additions and 55 deletions

View file

@ -1,21 +1,26 @@
# escape=`
# use windows server core image
FROM gcr.io/llvm-premerge-checks/agent-windows
# install java
RUN choco install -y openjdk
# get Jenkins swarm plugin
ENV SWARM_PLUGIN_URL="https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/swarm-client/3.17/swarm-client-3.17.jar"
ENV SWARM_PLUGIN_JAR="C:\jenkins\swarm-client.jar"
RUN powershell -NoProfile -InputFormat None -Command `
mkdir c:\jenkins ; `
Invoke-WebRequest -Uri %SWARM_PLUGIN_URL% -OutFile %SWARM_PLUGIN_JAR%
# network storage for build results
VOLUME C:\results
# start swarm plugin
COPY start_agent.bat c:\jenkins
# escape=`
# use windows server core image
FROM gcr.io/llvm-premerge-checks/agent-windows
# install java
RUN choco install -y openjdk
# get Jenkins swarm plugin
ENV SWARM_PLUGIN_URL="https://repo.jenkins-ci.org/releases/org/jenkins-ci/plugins/swarm-client/3.17/swarm-client-3.17.jar"
ENV SWARM_PLUGIN_JAR="C:\jenkins\swarm-client.jar"
RUN powershell -NoProfile -InputFormat None -Command `
mkdir c:\jenkins ; `
Invoke-WebRequest -Uri %SWARM_PLUGIN_URL% -OutFile %SWARM_PLUGIN_JAR%
# install gsutils to access Google Cloud Storage
RUN powershell -NoProfile -InputFormat None -Command `
(New-Object Net.WebClient).DownloadFile("https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe", "$env:Temp\GoogleCloudSDKInstaller.exe") ; `
& $env:Temp\GoogleCloudSDKInstaller.exe ; `
del $env:Temp\GoogleCloudSDKInstaller.exe
VOLUME C:\credentials
VOLUME C:\Temp
# start swarm plugin
COPY start_agent.bat c:\jenkins
CMD c:\jenkins\start_agent.bat

View file

@ -16,6 +16,11 @@ set JENKINS_SERVER=jenkins.local
set AGENT_ROOT=C:\ws
set WORKSPACE=%AGENT_ROOT%\workspace
if not exist "%WORKSPACE%" mkdir "%WORKSPACE%"
@rem authenticate gsutil
gcloud auth activate-service-account --key-file C:\credentials\build-agent-results_key.json
set TEMP=C:\TEMP
set TMP=%TEMP%
java -jar %SWARM_PLUGIN_JAR% -master http://%JENKINS_SERVER%:8080 -executors 1 -fsroot %AGENT_ROOT% -labels windows

View file

@ -1,35 +1,35 @@
# Copyright 2019 Google LLC
#
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://llvm.org/LICENSE.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# define command line arguments
param(
[Parameter(Mandatory=$true)][string]$IMAGE_NAME,
[Parameter(Mandatory=$false)][string]$CMD="",
[string]$token
)
# set script to stop on first error
$ErrorActionPreference = "Stop"
# some docs recommend setting 2GB memory limit
docker build --memory 2GB -t $IMAGE_NAME --build-arg token=$token "$PSScriptRoot\$IMAGE_NAME"
If ($LastExitCode -ne 0) {
exit
}
# mount a persistent workspace for experiments
docker run -it -v D:\:C:\ws $IMAGE_NAME $CMD
If ($LastExitCode -ne 0) {
exit
# Copyright 2019 Google LLC
#
# Licensed under the the Apache License v2.0 with LLVM Exceptions (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://llvm.org/LICENSE.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# define command line arguments
param(
[Parameter(Mandatory=$true)][string]$IMAGE_NAME,
[Parameter(Mandatory=$false)][string]$CMD="",
[string]$token
)
# set script to stop on first error
$ErrorActionPreference = "Stop"
# some docs recommend setting 2GB memory limit
docker build --memory 2GB -t $IMAGE_NAME --build-arg token=$token "$PSScriptRoot\$IMAGE_NAME"
If ($LastExitCode -ne 0) {
exit
}
# mount a persistent workspace for experiments
docker run -it -v D:\:C:\ws -v C:\credentials:C:\credentials $IMAGE_NAME $CMD
If ($LastExitCode -ne 0) {
exit
}

View file

@ -19,6 +19,11 @@ $JENKINS_SERVER="jenkins.local"
$AGENT_ROOT="D:\"
$SWARM_PLUGIN_JAR="C:\jenkins\swarm-client.jar"
# move temp dir to local SSD
mkdir D:\temp
$env:temp="D:\temp"
$env:tmp=$env:temp
java -jar ${SWARM_PLUGIN_JAR} `
-master http://${JENKINS_SERVER}:8080 `
-executors 1 `