From c6b813cb92bb6415390e7cc6e8b798a26479db7c Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Thu, 9 Apr 2020 00:28:36 -0700 Subject: [PATCH 1/2] Use text replacement to modify dockerfile once/day --- job_templates/ci_job.xml.em | 3 +++ windows_docker_resources/Dockerfile.msvc2019 | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/job_templates/ci_job.xml.em b/job_templates/ci_job.xml.em index e3393bc52..c4a5929af 100644 --- a/job_templates/ci_job.xml.em +++ b/job_templates/ci_job.xml.em @@ -357,6 +357,9 @@ echo "# BEGIN SECTION: Build DockerFile" set CONTAINER_NAME=ros2_windows_ci_msvc%CI_VISUAL_STUDIO_VERSION% set DOCKERFILE=windows_docker_resources\Dockerfile.msvc%CI_VISUAL_STUDIO_VERSION% +rem "Change dockerfile once per day to invalidate docker caches" +powershell "(Get-Content ${Env:DOCKERFILE}).replace('@todays_date', $(Get-Date).ToLongDateString()) | Set-Content ${Env:DOCKERFILE}" + rem "Finding the ReleaseId is much easier with powershell than cmd" powershell $(Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ReleaseId > release_id.txt set /p RELEASE_ID=< release_id.txt diff --git a/windows_docker_resources/Dockerfile.msvc2019 b/windows_docker_resources/Dockerfile.msvc2019 index 4cfa1f59e..7106c0f60 100644 --- a/windows_docker_resources/Dockerfile.msvc2019 +++ b/windows_docker_resources/Dockerfile.msvc2019 @@ -5,7 +5,6 @@ # To find this value run in powershell: # $(Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ReleaseId ARG WINDOWS_RELEASE_ID=1909 -ARG TODAYS_DATE=0 # Indicates that the windows image will be used as the base image. Must be same or older than host. # --isolation=hyperv is needed for both build/run if the image id is older than the host id @@ -84,7 +83,7 @@ RUN mkdir C:\ws WORKDIR C:\ci # Invalidate once a day to cause online installers to check for updates -RUN echo %TODAYS_DATE% +RUN echo "@todays_date" # Qt5 online installer ADD http://download.qt.io/official_releases/online_installers/qt-unified-windows-x86-online.exe C:\TEMP\ From 91f0d33aec2ebb9a0b94aeca66eed0d31cd83da6 Mon Sep 17 00:00:00 2001 From: Stephen Brawner Date: Thu, 9 Apr 2020 11:15:39 -0700 Subject: [PATCH 2/2] Remove build arg --- job_templates/ci_job.xml.em | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/job_templates/ci_job.xml.em b/job_templates/ci_job.xml.em index c4a5929af..a3dd39233 100644 --- a/job_templates/ci_job.xml.em +++ b/job_templates/ci_job.xml.em @@ -363,7 +363,7 @@ powershell "(Get-Content ${Env:DOCKERFILE}).replace('@todays_date', $(Get-Date). rem "Finding the ReleaseId is much easier with powershell than cmd" powershell $(Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').ReleaseId > release_id.txt set /p RELEASE_ID=< release_id.txt -set BUILD_ARGS=--build-arg WINDOWS_RELEASE_ID=%RELEASE_ID% --build-arg TODAYS_DATE="%date%" +set BUILD_ARGS=--build-arg WINDOWS_RELEASE_ID=%RELEASE_ID% docker build %BUILD_ARGS% -t %CONTAINER_NAME% -f %DOCKERFILE% windows_docker_resources echo "# END SECTION"