Refactor Dockerfile and update dependencies for improved build efficiency and runtime support
This commit is contained in:
parent
4cc9d151ed
commit
8c37334b20
10
Dockerfile
10
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 <container> 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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue