From 548e07d5d477aa7e9f54c2a7652036b11b5a4554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=BChnel?= Date: Thu, 20 Feb 2020 15:18:26 +0000 Subject: [PATCH] added versioning to windows docker containers --- containers/agent-windows-buildkite/Dockerfile | 3 +- containers/agent-windows-buildkite/VERSION | Bin 0 -> 8 bytes containers/agent-windows-jenkins/Dockerfile | 6 +-- containers/agent-windows-jenkins/VERSION | Bin 0 -> 8 bytes containers/agent-windows/Dockerfile | 4 +- containers/agent-windows/VERSION | Bin 0 -> 8 bytes containers/build_deploy.ps1 | 38 ++++++++++++++---- 7 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 containers/agent-windows-buildkite/VERSION create mode 100644 containers/agent-windows-jenkins/VERSION create mode 100644 containers/agent-windows/VERSION diff --git a/containers/agent-windows-buildkite/Dockerfile b/containers/agent-windows-buildkite/Dockerfile index 55ec56f..b79bb77 100644 --- a/containers/agent-windows-buildkite/Dockerfile +++ b/containers/agent-windows-buildkite/Dockerfile @@ -1,7 +1,8 @@ # escape=` # use windows server core image -FROM gcr.io/llvm-premerge-checks/agent-windows +ARG agent_windows_version +FROM gcr.io/llvm-premerge-checks/agent-windows:${agent_windows_version} # install buildkite agent as described in the documentation # https://buildkite.com/docs/agent/v3/windows diff --git a/containers/agent-windows-buildkite/VERSION b/containers/agent-windows-buildkite/VERSION new file mode 100644 index 0000000000000000000000000000000000000000..c7250cbdc15f21d024aa64ed135ba73e05b97b58 GIT binary patch literal 8 PcmezW&xnDSfr|kE5M}~L literal 0 HcmV?d00001 diff --git a/containers/agent-windows-jenkins/Dockerfile b/containers/agent-windows-jenkins/Dockerfile index 7e8cf96..454105b 100644 --- a/containers/agent-windows-jenkins/Dockerfile +++ b/containers/agent-windows-jenkins/Dockerfile @@ -1,7 +1,8 @@ # escape=` # use windows server core image -FROM gcr.io/llvm-premerge-checks/agent-windows +ARG agent_windows_version +FROM gcr.io/llvm-premerge-checks/agent-windows:$agent_windows_version # install java RUN choco install -y openjdk @@ -17,9 +18,6 @@ RUN powershell -NoProfile -InputFormat None -Command ` RUN pip install gsutil VOLUME C:\credentials -# configure gsutil -COPY .boto "C:\Users\ContainerAdministrator\.boto" - # install python dependencies for the scripts RUN pip install -r https://raw.githubusercontent.com/google/llvm-premerge-checks/master/scripts/requirements.txt diff --git a/containers/agent-windows-jenkins/VERSION b/containers/agent-windows-jenkins/VERSION new file mode 100644 index 0000000000000000000000000000000000000000..c7250cbdc15f21d024aa64ed135ba73e05b97b58 GIT binary patch literal 8 PcmezW&xnDSfr|kE5M}~L literal 0 HcmV?d00001 diff --git a/containers/agent-windows/Dockerfile b/containers/agent-windows/Dockerfile index ce4d91e..e983b88 100644 --- a/containers/agent-windows/Dockerfile +++ b/containers/agent-windows/Dockerfile @@ -1,8 +1,8 @@ # escape=` # use windows server core image -ARG version=ltsc2019 -FROM mcr.microsoft.com/windows/servercore:$version +ARG windows_version=ltsc2019 +FROM mcr.microsoft.com/windows/servercore:${windows_version} # install chocolately as package manager RUN powershell -NoProfile -InputFormat None -Command ` diff --git a/containers/agent-windows/VERSION b/containers/agent-windows/VERSION new file mode 100644 index 0000000000000000000000000000000000000000..c7250cbdc15f21d024aa64ed135ba73e05b97b58 GIT binary patch literal 8 PcmezW&xnDSfr|kE5M}~L literal 0 HcmV?d00001 diff --git a/containers/build_deploy.ps1 b/containers/build_deploy.ps1 index 430c52c..6d34732 100644 --- a/containers/build_deploy.ps1 +++ b/containers/build_deploy.ps1 @@ -17,21 +17,43 @@ param( [Parameter(Mandatory=$true)][string]$IMAGE_NAME ) -New-Variable -Name ROOT_DIR -Value (Get-Item $PSScriptRoot).Parent.FullName +$ROOT_DIR=(Get-Item $PSScriptRoot).Parent.FullName +. ${ROOT_DIR}\scripts\common.ps1 +$VERSION_FILE="VERSION" # get config options -Get-Content "${ROOT_DIR}/k8s_config" | Foreach-Object{ - $var = $_.Split('=') - New-Variable -Name $var[0] -Value $var[1] +Get-Content "${ROOT_DIR}\k8s_config" | Foreach-Object{ + if (! $_.StartsWith('#') ){ + $var = $_.Split('=') + New-Variable -Name $var[0] -Value $var[1] + } } -New-Variable -Name QUALIFIED_NAME -Value "${GCR_HOSTNAME}/${GCP_PROJECT}/${IMAGE_NAME}" +$QUALIFIED_NAME="${GCR_HOSTNAME}/${GCP_PROJECT}/${IMAGE_NAME}" Push-Location "$PSScriptRoot\$IMAGE_NAME" +$container_version=[int](Get-Content $VERSION_FILE) +$container_version+=1 +$agent_windows_version=Get-Content "../agent-windows/$VERSION_FILE" + +Write-Host "Building ${IMAGE_NAME}:${container_version}..." +Write-Host "Using windows-agent:${agent_windows_version}" # TODO: get current Windows version number from host via "cmd /c ver" # to solve these issues: https://stackoverflow.com/questions/43123851/unable-to-run-cygwin-in-windows-docker-container/52273489#52273489 -docker build -t $IMAGE_NAME --build-arg version=10.0.17763.1039 . -docker tag $IMAGE_NAME $QUALIFIED_NAME -docker push $QUALIFIED_NAME +$windows_version="10.0.17763.1039" + +Invoke-Call -ScriptBlock { + docker build . ` + -t ${IMAGE_NAME}:${container_version} ` + --build-arg windows_version=$windows_version ` + --build-arg agent_windows_version=$agent_windows_version + } +Invoke-Call -ScriptBlock { + docker tag ${IMAGE_NAME}:${container_version} ${QUALIFIED_NAME}:${container_version} +} +Invoke-Call -ScriptBlock { + docker push ${QUALIFIED_NAME}:$container_version +} +$container_version | Out-File $VERSION_FILE Pop-Location \ No newline at end of file