From 9cde1b4f5c3c4683df67c86868b11a8e4d31f1e4 Mon Sep 17 00:00:00 2001 From: Michael Grupp Date: Mon, 31 Aug 2020 15:59:36 +0200 Subject: [PATCH] Remove unnecessary bottlenecks from Dockerfiles to speed up CI. (#1511) This should solve #1506. - Use osrf/ros--desktop as base image for CI The basic ROS base image requires rosdep to install packages with many dependencies, e.g. rviz. Using the desktop base image should speed up CI because it has a good overlap with what we need and only little extra stuff. - Remove apt list only after installing everything. - Don't build protobuf 3 from source on Ubuntu 18 & 20. It should come with rosdep. Only on Ubuntu 16 we need to build manually because it ships with Protobuf 2. - No need to build Ceres from source on Ubuntu 18 & 20. The versions are greater or equal to 1.13, which is the one specified in the source build script. The apt packages should work just fine. The cartographer library is built from source in all cases, which is good to ensure that we always test compatibility with the latest version of it. --- Dockerfile.kinetic | 8 +++++--- Dockerfile.melodic | 13 +++++++------ Dockerfile.noetic | 13 +++++++------ 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Dockerfile.kinetic b/Dockerfile.kinetic index 72f0e41..77fe919 100644 --- a/Dockerfile.kinetic +++ b/Dockerfile.kinetic @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM ros:kinetic +FROM osrf/ros:kinetic-desktop ARG CARTOGRAPHER_VERSION=master @@ -20,7 +20,7 @@ ARG CARTOGRAPHER_VERSION=master ARG github_token # Xenial's base image doesn't ship with sudo. -RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y sudo # First, we invalidate the entire cache if cartographer-project/cartographer has # changed. This file's content changes whenever master changes. See: @@ -39,7 +39,7 @@ COPY cartographer_ros/package.xml catkin_ws/src/cartographer_ros/cartographer_ro COPY cartographer_ros_msgs/package.xml catkin_ws/src/cartographer_ros/cartographer_ros_msgs/ COPY cartographer_rviz/package.xml catkin_ws/src/cartographer_ros/cartographer_rviz/ COPY scripts/install_debs.sh cartographer_ros/scripts/ -RUN cartographer_ros/scripts/install_debs.sh && rm -rf /var/lib/apt/lists/* +RUN cartographer_ros/scripts/install_debs.sh # Install Abseil and proto3. RUN /catkin_ws/src/cartographer/scripts/install_abseil.sh @@ -75,6 +75,8 @@ RUN cartographer_ros/scripts/install.sh --pkg cartographer_rviz && \ cartographer_ros/scripts/catkin_test_results.sh build_isolated/cartographer_rviz COPY scripts/ros_entrypoint.sh / + +RUN rm -rf /var/lib/apt/lists/* # A BTRFS bug may prevent us from cleaning up these directories. # https://btrfs.wiki.kernel.org/index.php/Problem_FAQ#I_cannot_delete_an_empty_directory RUN rm -rf cartographer_ros catkin_ws || true diff --git a/Dockerfile.melodic b/Dockerfile.melodic index 38a9a89..55baf91 100644 --- a/Dockerfile.melodic +++ b/Dockerfile.melodic @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM ros:melodic +FROM osrf/ros:melodic-desktop ARG CARTOGRAPHER_VERSION=master @@ -20,7 +20,7 @@ ARG CARTOGRAPHER_VERSION=master ARG github_token # Bionic's base image doesn't ship with sudo. -RUN apt-get update && apt-get install -y sudo && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y sudo # First, we invalidate the entire cache if cartographer-project/cartographer has # changed. This file's content changes whenever master changes. See: @@ -39,11 +39,10 @@ COPY cartographer_ros/package.xml catkin_ws/src/cartographer_ros/cartographer_ro COPY cartographer_ros_msgs/package.xml catkin_ws/src/cartographer_ros/cartographer_ros_msgs/ COPY cartographer_rviz/package.xml catkin_ws/src/cartographer_ros/cartographer_rviz/ COPY scripts/install_debs.sh cartographer_ros/scripts/ -RUN cartographer_ros/scripts/install_debs.sh && rm -rf /var/lib/apt/lists/* +RUN cartographer_ros/scripts/install_debs.sh -# Install Abseil and proto3. +# Install Abseil. RUN /catkin_ws/src/cartographer/scripts/install_abseil.sh -RUN /catkin_ws/src/cartographer/scripts/install_proto3.sh # Build, install, and test all packages individually to allow caching. The # ordering of these steps must match the topological package ordering as @@ -57,7 +56,7 @@ RUN cartographer_ros/scripts/install.sh --pkg cartographer_ros_msgs && \ --catkin-make-args run_tests && \ cartographer_ros/scripts/catkin_test_results.sh build_isolated/cartographer_ros_msgs -RUN cartographer_ros/scripts/install.sh --pkg ceres-solver +RUN apt-get install -y libceres-dev RUN cartographer_ros/scripts/install.sh --pkg cartographer && \ cartographer_ros/scripts/install.sh --pkg cartographer --make-args test @@ -75,6 +74,8 @@ RUN cartographer_ros/scripts/install.sh --pkg cartographer_rviz && \ cartographer_ros/scripts/catkin_test_results.sh build_isolated/cartographer_rviz COPY scripts/ros_entrypoint.sh / + +RUN rm -rf /var/lib/apt/lists/* # A BTRFS bug may prevent us from cleaning up these directories. # https://btrfs.wiki.kernel.org/index.php/Problem_FAQ#I_cannot_delete_an_empty_directory RUN rm -rf cartographer_ros catkin_ws || true diff --git a/Dockerfile.noetic b/Dockerfile.noetic index 97cf6e1..87cd653 100644 --- a/Dockerfile.noetic +++ b/Dockerfile.noetic @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM ros:noetic +FROM osrf/ros:noetic-desktop ARG CARTOGRAPHER_VERSION=master @@ -24,7 +24,7 @@ ARG github_token ARG DEBIAN_FRONTEND=noninteractive # ROS Noetic's base image doesn't ship with sudo and git. -RUN apt-get update && apt-get install -y sudo git && rm -rf /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y sudo git # First, we invalidate the entire cache if cartographer-project/cartographer has # changed. This file's content changes whenever master changes. See: @@ -43,11 +43,10 @@ COPY cartographer_ros/package.xml catkin_ws/src/cartographer_ros/cartographer_ro COPY cartographer_ros_msgs/package.xml catkin_ws/src/cartographer_ros/cartographer_ros_msgs/ COPY cartographer_rviz/package.xml catkin_ws/src/cartographer_ros/cartographer_rviz/ COPY scripts/install_debs.sh cartographer_ros/scripts/ -RUN cartographer_ros/scripts/install_debs.sh && rm -rf /var/lib/apt/lists/* +RUN cartographer_ros/scripts/install_debs.sh -# Install Abseil and proto3. +# Install Abseil. RUN /catkin_ws/src/cartographer/scripts/install_abseil.sh -RUN /catkin_ws/src/cartographer/scripts/install_proto3.sh # Build, install, and test all packages individually to allow caching. The # ordering of these steps must match the topological package ordering as @@ -61,7 +60,7 @@ RUN cartographer_ros/scripts/install.sh --pkg cartographer_ros_msgs && \ --catkin-make-args run_tests && \ cartographer_ros/scripts/catkin_test_results.sh build_isolated/cartographer_ros_msgs -RUN cartographer_ros/scripts/install.sh --pkg ceres-solver +RUN apt-get install -y libceres-dev RUN cartographer_ros/scripts/install.sh --pkg cartographer && \ cartographer_ros/scripts/install.sh --pkg cartographer --make-args test @@ -79,6 +78,8 @@ RUN cartographer_ros/scripts/install.sh --pkg cartographer_rviz && \ cartographer_ros/scripts/catkin_test_results.sh build_isolated/cartographer_rviz COPY scripts/ros_entrypoint.sh / + +RUN rm -rf /var/lib/apt/lists/* # A BTRFS bug may prevent us from cleaning up these directories. # https://btrfs.wiki.kernel.org/index.php/Problem_FAQ#I_cannot_delete_an_empty_directory RUN rm -rf cartographer_ros catkin_ws || true