From 8c37334b208d1144f27e04c9697088f4bff726c2 Mon Sep 17 00:00:00 2001 From: Akash Shingha Date: Wed, 11 Mar 2026 18:43:51 +0200 Subject: [PATCH] Refactor Dockerfile and update dependencies for improved build efficiency and runtime support --- Dockerfile | 10 ++++------ apt-requirements.txt | 7 ++----- apt-runtime.txt | 6 ------ 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index bce32ce..16465e1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,22 +2,21 @@ FROM ros:humble-ros-base AS build SHELL ["/bin/bash", "-lc"] WORKDIR /ws -# Install OS packages first (cached layer when requirements.txt unchanged) +# Install build dependencies COPY apt-requirements.txt /tmp/requirements.txt RUN apt-get update \ && xargs -a /tmp/requirements.txt apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* /tmp/requirements.txt -# Copy package manifest(s) so rosdep can install system deps and this layer caches +# Copy package manifest and install rosdeps COPY package.xml ./package.xml +RUN add-apt-repository multiverse || true RUN source /opt/ros/humble/setup.bash \ && rosdep update || true \ && rosdep install -i --from-paths . --rosdistro humble -y || true -# Copy rest of the sources after deps to avoid busting the deps layer on code changes +# Copy sources and build COPY . . - -# Build with Ninja + ccache for faster incremental builds inside the container RUN source /opt/ros/humble/setup.bash \ && CCACHE_DIR=/ccache mkdir -p /ccache \ && chmod 777 /ccache \ @@ -39,7 +38,6 @@ RUN chmod +x /ros_entrypoint.sh ENV ROS_DISTRO=humble ## Make ROS and workspace overlays available for interactive shells -# This ensures `docker exec -it bash` has `ros2` on PATH RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash || true" > /etc/profile.d/ros2.sh \ && echo "[ -f /ws/install/setup.bash ] && source /ws/install/setup.bash" >> /etc/profile.d/ros2.sh \ && chmod +x /etc/profile.d/ros2.sh diff --git a/apt-requirements.txt b/apt-requirements.txt index 2166a05..81cd4a6 100644 --- a/apt-requirements.txt +++ b/apt-requirements.txt @@ -1,18 +1,15 @@ python3-colcon-common-extensions -python3-pip -git build-essential cmake pkg-config libopencv-dev python3-opencv -curl python3-rosdep python3-rosdistro +software-properties-common libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-good1.0-dev -libgstreamer-plugins-bad1.0-dev libgstrtspserver-1.0-dev -ccache ninja-build +ccache diff --git a/apt-runtime.txt b/apt-runtime.txt index 9fa736c..c60c1d2 100644 --- a/apt-runtime.txt +++ b/apt-runtime.txt @@ -1,13 +1,7 @@ libgstreamer1.0-0 gstreamer1.0-plugins-base gstreamer1.0-plugins-good -gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly libgstrtspserver-1.0-0 python3-opencv -libopencv-dev ros-humble-ros2cli -ros-humble-rclpy - -net-tools -iputils-ping