Skip to content

Commit ae21ad9

Browse files
authored
Merge pull request #1 from Ryanf55/multistage-docker-and-cache-fixing
Add multistage, fix cache, add rviz dep
2 parents 5412dfe + 732e49b commit ae21ad9

File tree

4 files changed

+28
-21
lines changed

4 files changed

+28
-21
lines changed

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.vscode/*
2+
html/*
3+
build/*
4+
install/*
5+
log/*
6+
LICENSE

Dockerfile

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
# Use the official ROS 2 humble base image
2-
FROM ros:humble
2+
ARG ROS_DISTRO=humble
3+
FROM ros:${ROS_DISTRO} as deps
34

45
# Set the working directory
5-
WORKDIR /root/ros2_ws/src
6+
WORKDIR /root/ros2_ws
67

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"]
129

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"]
1918

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
2126

2227
# Source the ROS2 setup file
2328
RUN echo "source /root/ros2_ws/install/setup.bash" >> ~/.bashrc
24-
# Expose the default ROS 2 communication ports
25-
EXPOSE 11311
2629

2730
# Run a default command, e.g., starting a bash shell
2831
CMD ["bash"]

Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,3 @@ docker_build:
55
.PHONY : docker_run
66
docker_run:
77
docker run -it --net=host --ipc=host --privileged --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --volume="${XAUTHORITY}:/root/.Xauthority" --entrypoint /bin/bash gmg
8-
9-
10-
11-

package.xml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@
1919
<depend>libgdal-dev</depend>
2020
<depend>rclcpp</depend>
2121
<depend>yaml_cpp_vendor</depend>
22-
<exec_depend>ros2launch</exec_depend>
22+
2323
<exec_depend>grid_map_rviz_plugin</exec_depend>
24+
<exec_depend>ros2launch</exec_depend>
25+
<exec_depend>rviz2</exec_depend>
2426

2527
<export>
2628
<build_type>ament_cmake</build_type>

0 commit comments

Comments
 (0)