|
1 | 1 | # Use the official ROS 2 humble base image
|
2 |
| -FROM ros:humble |
| 2 | +ARG ROS_DISTRO=humble |
| 3 | +FROM ros:${ROS_DISTRO} as deps |
3 | 4 |
|
4 | 5 | # Set the working directory
|
5 |
| -WORKDIR /root/ros2_ws/src |
| 6 | +WORKDIR /root/ros2_ws |
6 | 7 |
|
7 |
| -COPY . . |
8 |
| -# Install additional dependencies |
9 |
| -RUN apt-get update \ |
10 |
| - && apt-get -y --quiet --no-install-recommends install \ |
11 |
| - ros-humble-rviz2 |
| 8 | +SHELL ["/bin/bash", "-c"] |
12 | 9 |
|
13 |
| -# Set environment variables |
14 |
| -ENV ROS_VERSION 2 |
15 |
| -WORKDIR /root/ros2_ws |
16 |
| -RUN . /opt/ros/humble/setup.sh |
17 |
| -RUN rosdep update |
18 |
| -RUN rosdep install --from-paths src --ignore-src -y |
| 10 | +RUN source /opt/ros/${ROS_DISTRO}/setup.bash |
| 11 | +RUN --mount=type=bind,source=package.xml,target=src/grid_map_geo/package.xml \ |
| 12 | + apt update && \ |
| 13 | + rosdep update && \ |
| 14 | + rosdep install --from-paths src --ignore-src -y |
| 15 | + |
| 16 | +# Run a default command, e.g., starting a bash shell |
| 17 | +CMD ["bash"] |
19 | 18 |
|
20 |
| -RUN . /opt/ros/humble/setup.sh && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-up-to grid_map_geo |
| 19 | +FROM deps as builder |
| 20 | +ARG CMAKE_BUILD_TYPE=Release |
| 21 | + |
| 22 | +RUN source /opt/ros/${ROS_DISTRO}/setup.bash |
| 23 | +COPY . . |
| 24 | +RUN source /opt/ros/${ROS_DISTRO}/setup.bash && \ |
| 25 | + colcon build --cmake-args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} --packages-up-to grid_map_geo |
21 | 26 |
|
22 | 27 | # Source the ROS2 setup file
|
23 | 28 | RUN echo "source /root/ros2_ws/install/setup.bash" >> ~/.bashrc
|
24 |
| -# Expose the default ROS 2 communication ports |
25 |
| -EXPOSE 11311 |
26 | 29 |
|
27 | 30 | # Run a default command, e.g., starting a bash shell
|
28 | 31 | CMD ["bash"]
|
|
0 commit comments