Skip to content

Commit

Permalink
Try to do the substitution before the Dockerfile.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Sep 3, 2024
1 parent 27c9340 commit e7cb1e7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion job_templates/ci_job.xml.em
Original file line number Diff line number Diff line change
Expand Up @@ -242,14 +242,17 @@ rmdir /S /Q ws workspace "work space"
echo "# BEGIN SECTION: Build DockerFile"
set CONTAINER_NAME=ros2_windows_ci_%CI_ROS_DISTRO%
set DOCKERFILE=windows_docker_resources\Dockerfile
set SOLOFILE=windows_docker_resources\install_ros2_%CI_ROS_DISTRO%.json

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}"

powershell -noexit "(Get-Content ${Env:SOLOFILE}).replace('@vs_version', ${Env:VISUAL_STUDIO_VERSION}) | Set-Content ${Env:SOLOFILE}"

rem "Finding the Release Version is much easier with powershell than cmd"
powershell $(Get-ItemProperty -Path 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\Update\TargetingInfo\Installed\Server.OS.amd64' -Name Version).Version > release_version.txt
set /p RELEASE_VERSION=&lt; release_version.txt
set BUILD_ARGS=--build-arg WINDOWS_RELEASE_VERSION=%RELEASE_VERSION% --build-arg ROS_DISTRO=%CI_ROS_DISTRO% --build-arg VISUAL_STUDIO_VERSION=%CI_VISUAL_STUDIO_VERSION%
set BUILD_ARGS=--build-arg WINDOWS_RELEASE_VERSION=%RELEASE_VERSION% --build-arg ROS_DISTRO=%CI_ROS_DISTRO%
docker build %BUILD_ARGS% -t %CONTAINER_NAME% -f %DOCKERFILE% windows_docker_resources || exit /b !ERRORLEVEL!
echo "# END SECTION"

Expand Down
5 changes: 4 additions & 1 deletion job_templates/packaging_job.xml.em
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,17 @@ rmdir /S /Q ws workspace

set CONTAINER_NAME=ros2_windows_ci_%CI_ROS_DISTRO%
set DOCKERFILE=windows_docker_resources\Dockerfile
set SOLOFILE=windows_docker_resources\install_ros2_%CI_ROS_DISTRO%.json

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}"

powershell -noexit "(Get-Content ${Env:SOLOFILE}).replace('@vs_version', ${Env:VISUAL_STUDIO_VERSION}) | Set-Content ${Env:SOLOFILE}"

rem "Finding the Release Version is much easier with powershell than cmd"
powershell $(Get-ItemProperty -Path 'HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\Update\TargetingInfo\Installed\Server.OS.amd64' -Name Version).Version > release_version.txt
set /p RELEASE_VERSION=&lt; release_version.txt
set BUILD_ARGS=--build-arg WINDOWS_RELEASE_VERSION=%RELEASE_VERSION% --build-arg ROS_DISTRO=%CI_ROS_DISTRO% --build-arg VISUAL_STUDIO_VERSION=%CI_VISUAL_STUDIO_VERSION%
set BUILD_ARGS=--build-arg WINDOWS_RELEASE_VERSION=%RELEASE_VERSION% --build-arg ROS_DISTRO=%CI_ROS_DISTRO%
docker build %BUILD_ARGS% -t %CONTAINER_NAME% -f %DOCKERFILE% windows_docker_resources || exit /b !ERRORLEVEL!
echo "# END SECTION"

Expand Down
3 changes: 0 additions & 3 deletions windows_docker_resources/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ RUN copy /b C:\TEMP\rticonnextdds-src\rti_connext_dds-6.0.1-pro-target-x64Win64V
# ROS_DISTRO argument should be set to install dependencies for the target ROS version.
ARG ROS_DISTRO

ARG VISUAL_STUDIO_VERSION

COPY install_ros2_${ROS_DISTRO}.json C:\TEMP\
RUN powershell -noexit "(Get-Content C:\TEMP\install_ros2_${env:ROS_DISTRO}.json).replace('@vs_version', ${env:VISUAL_STUDIO_VERSION}) | Set-Content C:\TEMP\install_ros2_${env:ROS_DISTRO}.json"
RUN type C:\TEMP\install_ros2_rolling.json
COPY solo.rb C:\TEMP\
COPY ros2-cookbooks\ C:\TEMP\ros2-cookbooks
Expand Down

0 comments on commit e7cb1e7

Please sign in to comment.