From 0b3d94af2352da99d1d11463310e5bfd0928160b Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Wed, 30 Oct 2024 12:27:27 +0000 Subject: [PATCH 1/3] add option to disable installation of ros-core --- .gitlab-ci/docker-ros.yml | 1 + README.md | 4 ++++ action.yml | 7 +++++++ docker/Dockerfile | 18 ++++++++++++------ scripts/build.sh | 1 + scripts/ci.sh | 1 + 6 files changed, 26 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci/docker-ros.yml b/.gitlab-ci/docker-ros.yml index 5d418b1..f4c33bd 100644 --- a/.gitlab-ci/docker-ros.yml +++ b/.gitlab-ci/docker-ros.yml @@ -30,6 +30,7 @@ variables: ENABLE_PUSH_AS_LATEST: 'false' # Push images with tag `latest`/`latest-dev` in addition to the configured image names RMW_IMPLEMENTATION: 'rmw_cyclonedds_cpp' # RMW implementation to use (only for ROS 2) ROS_DISTRO: '' # ROS Distro (required if ROS is not installed in `base-image`) + DISABLE_ROS_INSTALLATION: 'false' # Disable automatic installation of `ros-$ROS_DISTRO-ros-core` package, e.g., if ROS is already installed in `base-image` and package is not available for the OS GIT_HTTPS_SERVER: ${CI_SERVER_HOST} # Server URL (without protocol) for cloning private Git repositories via HTTPS GIT_HTTPS_USER: gitlab-ci-token # Username for cloning private Git repositories via HTTPS GIT_HTTPS_PASSWORD: ${CI_JOB_TOKEN} # Password for cloning private Git repositories via HTTPS diff --git a/README.md b/README.md index f08360e..07a9ef6 100644 --- a/README.md +++ b/README.md @@ -387,6 +387,10 @@ The password of the custom user is set to its username (`dockeruser:dockeruser` - **`dev-image-tag` | `DEV_IMAGE_TAG`** Image tag of dev image *default:* `-dev` +- **`disable-ros-installation` | `DISABLE_ROS_INSTALLATION`** + Disable automatic installation of `ros-$ROS_DISTRO-ros-core` package + *e.g., if ROS is already installed in `base-image` and package is not available for the OS* + *default:* `false` - **`-` | `DOCKER_ROS_GIT_REF`** Git reference of *docker-ros* to run in CI *default:* `main` diff --git a/action.yml b/action.yml index a904e2b..bb78023 100644 --- a/action.yml +++ b/action.yml @@ -65,6 +65,10 @@ inputs: ros-distro: description: "ROS Distro (required if ROS is not installed in `base-image`)" + disable-ros-installation: + description: "Disable automatic installation of `ros-$ROS_DISTRO-ros-core` package, e.g., if ROS is already installed in `base-image` and package is not available for the OS" + default: false + git-https-server: description: "Server URL (without protocol) for cloning private Git repositories via HTTPS" default: "github.com" @@ -229,6 +233,7 @@ runs: SLIM_BUILD_ARGS: ${{ inputs.slim-build-args }} RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }} ROS_DISTRO: ${{ inputs.ros-distro }} + DISABLE_ROS_INSTALLATION: ${{ inputs.disable-ros-installation }} GIT_HTTPS_SERVER: ${{ inputs.git-https-server }} GIT_HTTPS_USER: ${{ inputs.git-https-user }} GIT_HTTPS_PASSWORD: ${{ inputs.git-https-password }} @@ -291,6 +296,7 @@ runs: ENABLE_SINGLEARCH_PUSH: ${{ inputs.enable-singlearch-push }} RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }} ROS_DISTRO: ${{ inputs.ros-distro }} + DISABLE_ROS_INSTALLATION: ${{ inputs.disable-ros-installation }} GIT_HTTPS_SERVER: ${{ inputs.git-https-server }} GIT_HTTPS_USER: ${{ inputs.git-https-user }} GIT_HTTPS_PASSWORD: ${{ inputs.git-https-password }} @@ -331,6 +337,7 @@ runs: ENABLE_SINGLEARCH_PUSH: ${{ inputs.enable-singlearch-push }} RMW_IMPLEMENTATION: ${{ inputs.rmw-implementation }} ROS_DISTRO: ${{ inputs.ros-distro }} + DISABLE_ROS_INSTALLATION: ${{ inputs.disable-ros-installation }} GIT_HTTPS_SERVER: ${{ inputs.git-https-server }} GIT_HTTPS_USER: ${{ inputs.git-https-user }} GIT_HTTPS_PASSWORD: ${{ inputs.git-https-password }} diff --git a/docker/Dockerfile b/docker/Dockerfile index 37756ca..e481976 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -28,13 +28,16 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* # install ROS bootstrapping tools +ARG DISABLE_ROS_INSTALLATION="false" RUN apt-get update && \ apt-get install -y \ git \ python3-rosdep \ - python3-vcstool \ - ros-${ROS_DISTRO}-ros-core \ - && rm -rf /var/lib/apt/lists/* + python3-vcstool && \ + if [[ "$DISABLE_ROS_INSTALLATION" != "true" ]]; then \ + apt-get install -y ros-${ROS_DISTRO}-ros-core; \ + fi && \ + rm -rf /var/lib/apt/lists/* # copy contents of repository COPY . src/target @@ -178,14 +181,17 @@ ARG ADDITIONAL_FILES_DIR="docker/additional-files" ADD ${ADDITIONAL_FILES_DIR}* /docker-ros/additional-files/ # install essential build tools and dependencies for install script +ARG DISABLE_ROS_INSTALLATION="false" RUN apt-get update && \ apt-get install -y \ build-essential \ gosu \ python-is-python3 \ - python3-pip \ - ros-${ROS_DISTRO}-ros-core \ - && rm -rf /var/lib/apt/lists/* + python3-pip && \ + if [[ "$DISABLE_ROS_INSTALLATION" != "true" ]]; then \ + apt-get install -y ros-${ROS_DISTRO}-ros-core; \ + fi && \ + rm -rf /var/lib/apt/lists/* # configure pip RUN python -m pip config --global set global.break-system-packages true diff --git a/scripts/build.sh b/scripts/build.sh index 83b59a6..0830164 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -19,6 +19,7 @@ build_image() { --build-arg COMMAND="${COMMAND}" \ $(if [[ -n "${RMW_IMPLEMENTATION}" ]]; then echo "--build-arg RMW_IMPLEMENTATION=${RMW_IMPLEMENTATION}"; fi) \ $(if [[ -n "${ROS_DISTRO}" ]]; then echo "--build-arg ROS_DISTRO=${ROS_DISTRO}"; fi) \ + $(if [[ -n "${DISABLE_ROS_INSTALLATION}" ]]; then echo "--build-arg DISABLE_ROS_INSTALLATION=${DISABLE_ROS_INSTALLATION}"; fi) \ $(if [[ -n "${GIT_HTTPS_SERVER}" ]]; then echo "--build-arg GIT_HTTPS_SERVER=${GIT_HTTPS_SERVER}"; fi) \ $(if [[ -n "${GIT_HTTPS_USER}" ]]; then echo "--build-arg GIT_HTTPS_USER=${GIT_HTTPS_USER}"; fi) \ $(if [[ -n "${GIT_HTTPS_PASSWORD}" ]]; then echo "--build-arg GIT_HTTPS_PASSWORD=${GIT_HTTPS_PASSWORD}"; fi) \ diff --git a/scripts/ci.sh b/scripts/ci.sh index 0dda562..8679a10 100755 --- a/scripts/ci.sh +++ b/scripts/ci.sh @@ -27,6 +27,7 @@ SLIM_BUILD_ARGS="${SLIM_BUILD_ARGS:-'--sensor-ipc-mode proxy --continue-after=10 ENABLE_SINGLEARCH_PUSH="${ENABLE_SINGLEARCH_PUSH:-false}" RMW_IMPLEMENTATION="${RMW_IMPLEMENTATION:-}" ROS_DISTRO="${ROS_DISTRO:-}" +DISABLE_ROS_INSTALLATION="${DISABLE_ROS_INSTALLATION:-}" GIT_HTTPS_SERVER="${GIT_HTTPS_SERVER:-}" GIT_HTTPS_USER="${GIT_HTTPS_USER:-}" GIT_HTTPS_PASSWORD="${GIT_HTTPS_PASSWORD:-}" From 88834a0adbcd7e09164e3498002d18274f861348 Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Wed, 30 Oct 2024 16:17:19 +0000 Subject: [PATCH 2/3] temporarily add build of fastcdr to rmw_zenoh_cpp installation --- docker/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/docker/Dockerfile b/docker/Dockerfile index e481976..22375ca 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -223,6 +223,7 @@ RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ if [[ "$RMW_IMPLEMENTATION" == "rmw_zenoh_cpp" ]]; then \ mkdir -p /opt/ws_rmw_zenoh/src && \ git clone https://github.com/ros2/rmw_zenoh.git /opt/ws_rmw_zenoh/src/rmw_zenoh && \ + git clone https://github.com/eProsima/Fast-CDR.git /opt/ws_rmw_zenoh/src/Fast-CDR && \ rosdep init || true && \ rosdep update --rosdistro $ROS_DISTRO && \ apt-get update && \ From f2884579efcab8451aa47d8ec5e6455e4a648d9b Mon Sep 17 00:00:00 2001 From: Lennart Reiher Date: Thu, 7 Nov 2024 00:23:56 +0100 Subject: [PATCH 3/3] only install fastcdr for ubuntu22 --- docker/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 22375ca..c29b10c 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -223,7 +223,9 @@ RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ if [[ "$RMW_IMPLEMENTATION" == "rmw_zenoh_cpp" ]]; then \ mkdir -p /opt/ws_rmw_zenoh/src && \ git clone https://github.com/ros2/rmw_zenoh.git /opt/ws_rmw_zenoh/src/rmw_zenoh && \ - git clone https://github.com/eProsima/Fast-CDR.git /opt/ws_rmw_zenoh/src/Fast-CDR && \ + if [[ "$UBUNTU_VERSION" == "22.04" ]]; then \ + git clone https://github.com/eProsima/Fast-CDR.git /opt/ws_rmw_zenoh/src/Fast-CDR ; \ + fi && \ rosdep init || true && \ rosdep update --rosdistro $ROS_DISTRO && \ apt-get update && \