From 77deb1f1df8c803876da660014f074b1b67d2355 Mon Sep 17 00:00:00 2001 From: "R. Kent James" Date: Wed, 10 Jul 2024 14:21:11 -0700 Subject: [PATCH 1/3] Delete any existing UID user in Dockerfile --- .../templates/ci/ci_create_reconfigure_task.Dockerfile.em | 5 ++++- ros_buildfarm/templates/ci/ci_create_tasks.Dockerfile.em | 5 ++++- ros_buildfarm/templates/ci/create_workspace.Dockerfile.em | 5 ++++- .../devel/devel_create_reconfigure_task.Dockerfile.em | 5 ++++- .../templates/devel/devel_create_tasks.Dockerfile.em | 5 ++++- ros_buildfarm/templates/devel/devel_task.Dockerfile.em | 5 ++++- .../templates/doc/doc_create_reconfigure_task.Dockerfile.em | 5 ++++- ros_buildfarm/templates/doc/doc_create_task.Dockerfile.em | 5 ++++- .../templates/doc/doc_independent_task.Dockerfile.em | 5 ++++- ros_buildfarm/templates/doc/doc_metadata_task.Dockerfile.em | 5 ++++- ros_buildfarm/templates/doc/doc_task.Dockerfile.em | 5 ++++- .../templates/doc/rosdoc2_create_task.Dockerfile.em | 5 ++++- ros_buildfarm/templates/doc/rosdoc2_task.Dockerfile.em | 5 ++++- .../templates/misc/rosdistro_cache_task.Dockerfile.em | 5 ++++- .../release/deb/binarypkg_create_task.Dockerfile.em | 5 ++++- .../templates/release/deb/binarypkg_task.Dockerfile.em | 5 ++++- .../templates/release/deb/sourcepkg_task.Dockerfile.em | 5 ++++- .../release/release_check_sync_criteria_task.Dockerfile.em | 5 ++++- .../release/release_create_reconfigure_task.Dockerfile.em | 5 ++++- .../release/release_create_trigger_task.Dockerfile.em | 5 ++++- .../templates/snippet/add_buildfarm_user.Dockerfile.em | 3 +++ .../status/blocked_releases_page_task.Dockerfile.em | 5 ++++- .../status/blocked_source_entries_page_task.Dockerfile.em | 5 ++++- .../templates/status/release_compare_page_task.Dockerfile.em | 5 ++++- .../templates/status/release_status_page_task.Dockerfile.em | 5 ++++- 25 files changed, 99 insertions(+), 24 deletions(-) create mode 100644 ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em diff --git a/ros_buildfarm/templates/ci/ci_create_reconfigure_task.Dockerfile.em b/ros_buildfarm/templates/ci/ci_create_reconfigure_task.Dockerfile.em index 2fdaf31e2..457d7b68e 100644 --- a/ros_buildfarm/templates/ci/ci_create_reconfigure_task.Dockerfile.em +++ b/ros_buildfarm/templates/ci/ci_create_reconfigure_task.Dockerfile.em @@ -12,7 +12,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/ci/ci_create_tasks.Dockerfile.em b/ros_buildfarm/templates/ci/ci_create_tasks.Dockerfile.em index 35c8bb2db..fdbefc435 100644 --- a/ros_buildfarm/templates/ci/ci_create_tasks.Dockerfile.em +++ b/ros_buildfarm/templates/ci/ci_create_tasks.Dockerfile.em @@ -18,7 +18,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/ci/create_workspace.Dockerfile.em b/ros_buildfarm/templates/ci/create_workspace.Dockerfile.em index 068e65a08..c8f22c7be 100644 --- a/ros_buildfarm/templates/ci/create_workspace.Dockerfile.em +++ b/ros_buildfarm/templates/ci/create_workspace.Dockerfile.em @@ -28,7 +28,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/devel/devel_create_reconfigure_task.Dockerfile.em b/ros_buildfarm/templates/devel/devel_create_reconfigure_task.Dockerfile.em index 08bfcd2c6..a888bbf53 100644 --- a/ros_buildfarm/templates/devel/devel_create_reconfigure_task.Dockerfile.em +++ b/ros_buildfarm/templates/devel/devel_create_reconfigure_task.Dockerfile.em @@ -12,7 +12,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/devel/devel_create_tasks.Dockerfile.em b/ros_buildfarm/templates/devel/devel_create_tasks.Dockerfile.em index ce9c321bd..fbf046b0d 100644 --- a/ros_buildfarm/templates/devel/devel_create_tasks.Dockerfile.em +++ b/ros_buildfarm/templates/devel/devel_create_tasks.Dockerfile.em @@ -18,7 +18,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @[if require_gpu_support]@ @(TEMPLATE( diff --git a/ros_buildfarm/templates/devel/devel_task.Dockerfile.em b/ros_buildfarm/templates/devel/devel_task.Dockerfile.em index 5f9c02437..b72fb5b83 100644 --- a/ros_buildfarm/templates/devel/devel_task.Dockerfile.em +++ b/ros_buildfarm/templates/devel/devel_task.Dockerfile.em @@ -24,7 +24,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/setup_nvidia_docker2.Dockerfile.em' diff --git a/ros_buildfarm/templates/doc/doc_create_reconfigure_task.Dockerfile.em b/ros_buildfarm/templates/doc/doc_create_reconfigure_task.Dockerfile.em index 7f1beb9dd..fb0121577 100644 --- a/ros_buildfarm/templates/doc/doc_create_reconfigure_task.Dockerfile.em +++ b/ros_buildfarm/templates/doc/doc_create_reconfigure_task.Dockerfile.em @@ -12,7 +12,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/doc/doc_create_task.Dockerfile.em b/ros_buildfarm/templates/doc/doc_create_task.Dockerfile.em index cad310b4b..385d59e23 100644 --- a/ros_buildfarm/templates/doc/doc_create_task.Dockerfile.em +++ b/ros_buildfarm/templates/doc/doc_create_task.Dockerfile.em @@ -11,7 +11,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/doc/doc_independent_task.Dockerfile.em b/ros_buildfarm/templates/doc/doc_independent_task.Dockerfile.em index 96c7dec76..5d9a4c88c 100644 --- a/ros_buildfarm/templates/doc/doc_independent_task.Dockerfile.em +++ b/ros_buildfarm/templates/doc/doc_independent_task.Dockerfile.em @@ -12,7 +12,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/doc/doc_metadata_task.Dockerfile.em b/ros_buildfarm/templates/doc/doc_metadata_task.Dockerfile.em index 3946a9c4c..12b963be8 100644 --- a/ros_buildfarm/templates/doc/doc_metadata_task.Dockerfile.em +++ b/ros_buildfarm/templates/doc/doc_metadata_task.Dockerfile.em @@ -12,7 +12,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/doc/doc_task.Dockerfile.em b/ros_buildfarm/templates/doc/doc_task.Dockerfile.em index 6fae1f2e0..0292f0ce4 100644 --- a/ros_buildfarm/templates/doc/doc_task.Dockerfile.em +++ b/ros_buildfarm/templates/doc/doc_task.Dockerfile.em @@ -22,7 +22,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/set_environment_variables.Dockerfile.em', diff --git a/ros_buildfarm/templates/doc/rosdoc2_create_task.Dockerfile.em b/ros_buildfarm/templates/doc/rosdoc2_create_task.Dockerfile.em index f27a5b271..b4f53d3e2 100644 --- a/ros_buildfarm/templates/doc/rosdoc2_create_task.Dockerfile.em +++ b/ros_buildfarm/templates/doc/rosdoc2_create_task.Dockerfile.em @@ -11,7 +11,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/doc/rosdoc2_task.Dockerfile.em b/ros_buildfarm/templates/doc/rosdoc2_task.Dockerfile.em index 6c1e442e3..c68c88111 100644 --- a/ros_buildfarm/templates/doc/rosdoc2_task.Dockerfile.em +++ b/ros_buildfarm/templates/doc/rosdoc2_task.Dockerfile.em @@ -16,7 +16,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/misc/rosdistro_cache_task.Dockerfile.em b/ros_buildfarm/templates/misc/rosdistro_cache_task.Dockerfile.em index a4aa34249..53fedd64d 100644 --- a/ros_buildfarm/templates/misc/rosdistro_cache_task.Dockerfile.em +++ b/ros_buildfarm/templates/misc/rosdistro_cache_task.Dockerfile.em @@ -12,7 +12,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/release/deb/binarypkg_create_task.Dockerfile.em b/ros_buildfarm/templates/release/deb/binarypkg_create_task.Dockerfile.em index 5ecc9ff29..a537c218f 100644 --- a/ros_buildfarm/templates/release/deb/binarypkg_create_task.Dockerfile.em +++ b/ros_buildfarm/templates/release/deb/binarypkg_create_task.Dockerfile.em @@ -23,7 +23,10 @@ ENV DEBIAN_FRONTEND noninteractive ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/release/deb/binarypkg_task.Dockerfile.em b/ros_buildfarm/templates/release/deb/binarypkg_task.Dockerfile.em index bbf1dd046..f1762a433 100644 --- a/ros_buildfarm/templates/release/deb/binarypkg_task.Dockerfile.em +++ b/ros_buildfarm/templates/release/deb/binarypkg_task.Dockerfile.em @@ -28,7 +28,10 @@ ENV DEBIAN_FRONTEND noninteractive bazelrc_dir='/etc', ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/release/deb/sourcepkg_task.Dockerfile.em b/ros_buildfarm/templates/release/deb/sourcepkg_task.Dockerfile.em index b0074111c..e53cc99a0 100644 --- a/ros_buildfarm/templates/release/deb/sourcepkg_task.Dockerfile.em +++ b/ros_buildfarm/templates/release/deb/sourcepkg_task.Dockerfile.em @@ -17,7 +17,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/release/release_check_sync_criteria_task.Dockerfile.em b/ros_buildfarm/templates/release/release_check_sync_criteria_task.Dockerfile.em index 4fb4e1e91..0a74c63e7 100644 --- a/ros_buildfarm/templates/release/release_check_sync_criteria_task.Dockerfile.em +++ b/ros_buildfarm/templates/release/release_check_sync_criteria_task.Dockerfile.em @@ -12,7 +12,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/release/release_create_reconfigure_task.Dockerfile.em b/ros_buildfarm/templates/release/release_create_reconfigure_task.Dockerfile.em index 52f4dfaa2..5002f5ad7 100644 --- a/ros_buildfarm/templates/release/release_create_reconfigure_task.Dockerfile.em +++ b/ros_buildfarm/templates/release/release_create_reconfigure_task.Dockerfile.em @@ -12,7 +12,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/release/release_create_trigger_task.Dockerfile.em b/ros_buildfarm/templates/release/release_create_trigger_task.Dockerfile.em index 434a299ba..a7de37591 100644 --- a/ros_buildfarm/templates/release/release_create_trigger_task.Dockerfile.em +++ b/ros_buildfarm/templates/release/release_create_trigger_task.Dockerfile.em @@ -12,7 +12,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em b/ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em new file mode 100644 index 000000000..173d6fa5d --- /dev/null +++ b/ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em @@ -0,0 +1,3 @@ +# Add user 'buildfarm', removing any existing user with that UID +RUN if [ $(id -nu @(uid)) ]; then userdel -r $(id -nu @(uid)); fi +RUN useradd -u @(uid) -l -m buildfarm diff --git a/ros_buildfarm/templates/status/blocked_releases_page_task.Dockerfile.em b/ros_buildfarm/templates/status/blocked_releases_page_task.Dockerfile.em index a26c45155..05145ed4a 100644 --- a/ros_buildfarm/templates/status/blocked_releases_page_task.Dockerfile.em +++ b/ros_buildfarm/templates/status/blocked_releases_page_task.Dockerfile.em @@ -12,7 +12,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/status/blocked_source_entries_page_task.Dockerfile.em b/ros_buildfarm/templates/status/blocked_source_entries_page_task.Dockerfile.em index 85ea3c750..d049ed190 100644 --- a/ros_buildfarm/templates/status/blocked_source_entries_page_task.Dockerfile.em +++ b/ros_buildfarm/templates/status/blocked_source_entries_page_task.Dockerfile.em @@ -12,7 +12,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/status/release_compare_page_task.Dockerfile.em b/ros_buildfarm/templates/status/release_compare_page_task.Dockerfile.em index c02140ca2..b0594a47a 100644 --- a/ros_buildfarm/templates/status/release_compare_page_task.Dockerfile.em +++ b/ros_buildfarm/templates/status/release_compare_page_task.Dockerfile.em @@ -12,7 +12,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', diff --git a/ros_buildfarm/templates/status/release_status_page_task.Dockerfile.em b/ros_buildfarm/templates/status/release_status_page_task.Dockerfile.em index 620ecf6c1..3be6d839d 100644 --- a/ros_buildfarm/templates/status/release_status_page_task.Dockerfile.em +++ b/ros_buildfarm/templates/status/release_status_page_task.Dockerfile.em @@ -12,7 +12,10 @@ ENV DEBIAN_FRONTEND noninteractive timezone=timezone, ))@ -RUN useradd -u @uid -l -m buildfarm +@(TEMPLATE( + 'snippet/add_buildfarm_user.Dockerfile.em', + uid=uid, +))@ @(TEMPLATE( 'snippet/add_distribution_repositories.Dockerfile.em', From 84965a3b67245ac7d1dae9857104d463861a02aa Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Mon, 14 Oct 2024 13:00:56 -0500 Subject: [PATCH 2/3] Update ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em Co-authored-by: Tully Foote --- .../templates/snippet/add_buildfarm_user.Dockerfile.em | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em b/ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em index 173d6fa5d..e0c2fab95 100644 --- a/ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em +++ b/ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em @@ -1,3 +1,3 @@ # Add user 'buildfarm', removing any existing user with that UID -RUN if [ $(id -nu @(uid)) ]; then userdel -r $(id -nu @(uid)); fi +RUN if [ $(id -nu @(uid)) ]; then userdel -r $(id -nu @(uid)); fi && useradd -u @(uid) -l -m buildfarm RUN useradd -u @(uid) -l -m buildfarm From add822e31e132c7fac47c3c1330d5266d120a78e Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Mon, 14 Oct 2024 13:04:26 -0500 Subject: [PATCH 3/3] fixup! Update ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em --- ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em | 1 - 1 file changed, 1 deletion(-) diff --git a/ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em b/ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em index e0c2fab95..e121d3ac1 100644 --- a/ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em +++ b/ros_buildfarm/templates/snippet/add_buildfarm_user.Dockerfile.em @@ -1,3 +1,2 @@ # Add user 'buildfarm', removing any existing user with that UID RUN if [ $(id -nu @(uid)) ]; then userdel -r $(id -nu @(uid)); fi && useradd -u @(uid) -l -m buildfarm -RUN useradd -u @(uid) -l -m buildfarm