From 744361e38e7e889ce5db0aa764ed194414365289 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Thu, 17 Oct 2024 22:57:00 -0500 Subject: [PATCH] Use 'host' network in deb container builds The --network argument was added to 'docker build' in Docker 1.13 in 2017 and behaves like the --net argument to 'docker run'. We're already using --net=host during the actual deb build and during all of the RPM containers. The change here is to also use host networking during the build phase. The intent here is to support more self-contained building scenarios where a repository may be on localhost. --- ros_buildfarm/templates/release/deb/binarypkg_job.xml.em | 7 ++++--- ros_buildfarm/templates/release/deb/sourcepkg_job.xml.em | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ros_buildfarm/templates/release/deb/binarypkg_job.xml.em b/ros_buildfarm/templates/release/deb/binarypkg_job.xml.em index c547ca8e3..18fa14b73 100644 --- a/ros_buildfarm/templates/release/deb/binarypkg_job.xml.em +++ b/ros_buildfarm/templates/release/deb/binarypkg_job.xml.em @@ -119,7 +119,7 @@ but disabled since the package is blacklisted (or not whitelisted) in the config 'echo "# BEGIN SECTION: Build Dockerfile - binarydeb task"', 'cd $WORKSPACE/docker_generating_docker', 'python3 -u $WORKSPACE/ros_buildfarm/scripts/misc/docker_pull_baseimage.py', - 'docker build --force-rm -t binarydeb_task_generation.%s_%s_%s_%s_%s .' % (rosdistro_name, os_name, os_code_name, arch, pkg_name), + 'docker build --network=host --force-rm -t binarydeb_task_generation.%s_%s_%s_%s_%s .' % (rosdistro_name, os_name, os_code_name, arch, pkg_name), 'echo "# END SECTION"', '', 'echo "# BEGIN SECTION: Run Dockerfile - binarydeb task"', @@ -138,6 +138,7 @@ but disabled since the package is blacklisted (or not whitelisted) in the config ' --rm ' + ' --cidfile=$WORKSPACE/docker_generating_docker/docker.cid' + ' -e=TRAVIS=$TRAVIS' + + ' --net=host' + ' -e=ROS_BUILDFARM_PULL_REQUEST_BRANCH=$ROS_BUILDFARM_PULL_REQUEST_BRANCH' + ' -v $WORKSPACE/ros_buildfarm:/tmp/ros_buildfarm:ro' + ' -v $WORKSPACE/binarydeb:/tmp/binarydeb' + @@ -159,7 +160,7 @@ but disabled since the package is blacklisted (or not whitelisted) in the config '# build and run build_binarydeb Dockerfile', 'cd $WORKSPACE/docker_build_binarydeb', 'python3 -u $WORKSPACE/ros_buildfarm/scripts/misc/docker_pull_baseimage.py', - 'docker build --force-rm -t binarydeb_build.%s_%s_%s_%s_%s .' % (rosdistro_name, os_name, os_code_name, arch, pkg_name), + 'docker build --network=host --force-rm -t binarydeb_build.%s_%s_%s_%s_%s .' % (rosdistro_name, os_name, os_code_name, arch, pkg_name), 'echo "# END SECTION"', '', 'echo "# BEGIN SECTION: Run Dockerfile - build binarydeb"', @@ -224,7 +225,7 @@ but disabled since the package is blacklisted (or not whitelisted) in the config @# 'echo "# BEGIN SECTION: Build Dockerfile - install"', @# 'cd $WORKSPACE/docker_install_binarydeb', @# 'python3 -u $WORKSPACE/ros_buildfarm/scripts/misc/docker_pull_baseimage.py', -@# 'docker build --force-rm -t binarydeb_install.%s_%s_%s_%s_%s .' % (rosdistro_name, os_name, os_code_name, arch, pkg_name), +@# 'docker build --network=host --force-rm -t binarydeb_install.%s_%s_%s_%s_%s .' % (rosdistro_name, os_name, os_code_name, arch, pkg_name), @# 'echo "# END SECTION"', @# '', @# 'echo "# BEGIN SECTION: Run Dockerfile - install"', diff --git a/ros_buildfarm/templates/release/deb/sourcepkg_job.xml.em b/ros_buildfarm/templates/release/deb/sourcepkg_job.xml.em index 2b3101195..50e712e57 100644 --- a/ros_buildfarm/templates/release/deb/sourcepkg_job.xml.em +++ b/ros_buildfarm/templates/release/deb/sourcepkg_job.xml.em @@ -104,7 +104,7 @@ but disabled since the package is blacklisted (or not whitelisted) in the config 'echo "# BEGIN SECTION: Build Dockerfile - generate sourcedeb"', 'cd $WORKSPACE/docker_sourcedeb', 'python3 -u $WORKSPACE/ros_buildfarm/scripts/misc/docker_pull_baseimage.py', - 'docker build --force-rm -t sourcedeb.%s_%s_%s_%s .' % (rosdistro_name, os_name, os_code_name, pkg_name), + 'docker build --network=host --force-rm -t sourcedeb.%s_%s_%s_%s .' % (rosdistro_name, os_name, os_code_name, pkg_name), 'echo "# END SECTION"', '', 'echo "# BEGIN SECTION: Run Dockerfile - generate sourcedeb"',