/
/
/
1ARG ROS_DISTRO=jazzy
2
3# =============================================================================
4# Stage 1: ROS with visualization
5# =============================================================================
6FROM ros:${ROS_DISTRO}-ros-base AS ros
7ARG ROS_DISTRO
8
9WORKDIR /ros2_ws
10
11COPY fast_slam src/fast_slam
12COPY fast_slam_ros src/fast_slam_ros
13
14RUN apt-get update && \
15 rosdep update && \
16 rosdep install --from-paths src --ignore-src -r -y && \
17 rm -rf /var/lib/apt/lists/*
18
19RUN . /opt/ros/${ROS_DISTRO}/setup.sh && \
20 colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release && \
21 rm -rf build log src
22
23RUN echo "source /opt/ros/${ROS_DISTRO}/setup.bash" >> ~/.bashrc && \
24 echo "source /ros2_ws/install/setup.bash" >> ~/.bashrc
25
26CMD ["bash"]
27
28# =============================================================================
29# Stage 2: ROS with visualization and Gazebo simulation
30# =============================================================================
31FROM ros AS sim
32ARG ROS_DISTRO
33
34COPY fast_slam_gz src/fast_slam_gz
35
36RUN apt-get update && \
37 rosdep install --from-paths src --ignore-src -r -y && \
38 rm -rf /var/lib/apt/lists/*
39
40RUN . /opt/ros/${ROS_DISTRO}/setup.sh && \
41 . install/setup.sh && \
42 colcon build --packages-select-regex "fast_slam_gz.*" --cmake-args -DCMAKE_BUILD_TYPE=Release && \
43 rm -rf build log src
44
45CMD ["bash", "-c", "source /ros2_ws/install/setup.bash && ros2 launch fast_slam_ros_core fast_slam_ros.launch.py"]
46