From 93339b8a66e1a7f0471f80bc07f4430a53fb584f Mon Sep 17 00:00:00 2001 From: avcuenes Date: Thu, 18 Jan 2024 23:02:10 +0300 Subject: [PATCH 1/8] add dockerfile and makefile --- Dockerfile | 35 +++++++++++++++++++++++++++++++++++ Makefile | 11 +++++++++++ 2 files changed, 46 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6a5f6a0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +# Use the official ROS 2 humble base image +FROM ros:humble + +# Set the working directory +WORKDIR /ros2_workspace/src + +COPY . . +# Install additional dependencies +RUN apt-get update \ + && apt-get -y --quiet --no-install-recommends install \ + gcc \ + git \ + libxml2-dev \ + libxslt-dev \ + python3 \ + ros-humble-ament-cmake-clang-format\ + ros-humble-rviz2 + +# Set environment variables +ENV ROS_DISTRO humble +ENV ROS_VERSION 2 +WORKDIR /ros2_workspace +RUN . /opt/ros/humble/setup.sh +RUN rosdep update +RUN rosdep install --from-paths src --ignore-src -y + +RUN . /opt/ros/humble/setup.sh && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-up-to grid_map_geo + +# Source the ROS2 setup file +RUN echo "source /ros2_workspace/install/setup.bash" >> ~/.bashrc +# Expose the default ROS 2 communication ports +EXPOSE 11311 + +# Run a default command, e.g., starting a bash shell +CMD ["bash"] \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..50865b8 --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +.PHONY : docker_build +docker_build: + docker build -t gmg . + +.PHONY : docker_run +docker_run: + 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 + + + + From 43d09789856050cc9b4f3618efa84b2a59ad001f Mon Sep 17 00:00:00 2001 From: enesavcu Date: Fri, 19 Jan 2024 07:39:57 +0300 Subject: [PATCH 2/8] Update Dockerfile change workspace name Co-authored-by: Ryan --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6a5f6a0..b4abc85 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ FROM ros:humble # Set the working directory -WORKDIR /ros2_workspace/src +WORKDIR /root/ros2_ws/src COPY . . # Install additional dependencies From 64ef3cf7dfb20531da742616e6a24841abce454c Mon Sep 17 00:00:00 2001 From: enesavcu Date: Fri, 19 Jan 2024 07:40:17 +0300 Subject: [PATCH 3/8] Update Dockerfile delete ROS_DISTRO Co-authored-by: Ryan --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index b4abc85..e4b5094 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,7 +17,6 @@ RUN apt-get update \ ros-humble-rviz2 # Set environment variables -ENV ROS_DISTRO humble ENV ROS_VERSION 2 WORKDIR /ros2_workspace RUN . /opt/ros/humble/setup.sh From 558dd430cc8eea158d54fe4acd941aee04625386 Mon Sep 17 00:00:00 2001 From: enesavcu Date: Fri, 19 Jan 2024 07:40:33 +0300 Subject: [PATCH 4/8] Update Dockerfile change workspace name again Co-authored-by: Ryan --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e4b5094..6b88d8e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN apt-get update \ # Set environment variables ENV ROS_VERSION 2 -WORKDIR /ros2_workspace +WORKDIR /root/ros2_ws RUN . /opt/ros/humble/setup.sh RUN rosdep update RUN rosdep install --from-paths src --ignore-src -y From 2b676efa265e07ce3dd7c8e0468ee296be520a7f Mon Sep 17 00:00:00 2001 From: avcuenes Date: Fri, 19 Jan 2024 09:42:02 +0300 Subject: [PATCH 5/8] add new line --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6a5f6a0..89c914d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,4 +32,5 @@ RUN echo "source /ros2_workspace/install/setup.bash" >> ~/.bashrc EXPOSE 11311 # Run a default command, e.g., starting a bash shell -CMD ["bash"] \ No newline at end of file +CMD ["bash"] + From 5412dfe2cee2b6cdb15ae18f82ae59828e265bc4 Mon Sep 17 00:00:00 2001 From: avcuenes Date: Fri, 19 Jan 2024 15:41:20 +0300 Subject: [PATCH 6/8] delete unnecessary installation and change workspace name --- Dockerfile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index e928293..6f8f472 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,12 +8,6 @@ COPY . . # Install additional dependencies RUN apt-get update \ && apt-get -y --quiet --no-install-recommends install \ - gcc \ - git \ - libxml2-dev \ - libxslt-dev \ - python3 \ - ros-humble-ament-cmake-clang-format\ ros-humble-rviz2 # Set environment variables @@ -26,7 +20,7 @@ RUN rosdep install --from-paths src --ignore-src -y RUN . /opt/ros/humble/setup.sh && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-up-to grid_map_geo # Source the ROS2 setup file -RUN echo "source /ros2_workspace/install/setup.bash" >> ~/.bashrc +RUN echo "source /root/ros2_ws/install/setup.bash" >> ~/.bashrc # Expose the default ROS 2 communication ports EXPOSE 11311 From e250038601daba0d9cbd8877a95bb0a4c9a4225f Mon Sep 17 00:00:00 2001 From: Ryan Friedman Date: Fri, 19 Jan 2024 19:39:32 -0700 Subject: [PATCH 7/8] Add multistage, fix cache, add rviz dep * This complets the requests for the PR * Bind mounts on the build reduce cache busting * Add default bash shell * Added parameters for the build type and ROS distro to use Signed-off-by: Ryan Friedman --- Dockerfile | 35 +++++++++++++++++++---------------- Makefile | 4 ---- package.xml | 4 +++- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6f8f472..cf74634 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,31 @@ # Use the official ROS 2 humble base image -FROM ros:humble +ARG ROS_DISTRO=humble +FROM ros:${ROS_DISTRO} as deps # Set the working directory -WORKDIR /root/ros2_ws/src +WORKDIR /root/ros2_ws -COPY . . -# Install additional dependencies -RUN apt-get update \ - && apt-get -y --quiet --no-install-recommends install \ - ros-humble-rviz2 +SHELL ["/bin/bash", "-c"] -# Set environment variables -ENV ROS_VERSION 2 -WORKDIR /root/ros2_ws -RUN . /opt/ros/humble/setup.sh -RUN rosdep update -RUN rosdep install --from-paths src --ignore-src -y +RUN source /opt/ros/${ROS_DISTRO}/setup.bash +RUN --mount=type=bind,source=package.xml,target=src/grid_map_geo/package.xml \ + apt update && \ + rosdep update && \ + rosdep install --from-paths src --ignore-src -y + +# Run a default command, e.g., starting a bash shell +CMD ["bash"] -RUN . /opt/ros/humble/setup.sh && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release --packages-up-to grid_map_geo +FROM deps as builder +ARG CMAKE_BUILD_TYPE=Release + +RUN source /opt/ros/${ROS_DISTRO}/setup.bash +COPY . . +RUN source /opt/ros/${ROS_DISTRO}/setup.bash && \ + colcon build --cmake-args -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} --packages-up-to grid_map_geo # Source the ROS2 setup file RUN echo "source /root/ros2_ws/install/setup.bash" >> ~/.bashrc -# Expose the default ROS 2 communication ports -EXPOSE 11311 # Run a default command, e.g., starting a bash shell CMD ["bash"] diff --git a/Makefile b/Makefile index 50865b8..0491396 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,3 @@ docker_build: .PHONY : docker_run docker_run: 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 - - - - diff --git a/package.xml b/package.xml index ac5463e..9524e52 100644 --- a/package.xml +++ b/package.xml @@ -19,8 +19,10 @@ libgdal-dev rclcpp yaml_cpp_vendor - ros2launch + grid_map_rviz_plugin + ros2launch + rviz2 ament_cmake From 732e49be513a3779855f597c2f76aec2f3fdd27d Mon Sep 17 00:00:00 2001 From: Ryan Friedman Date: Fri, 19 Jan 2024 21:59:16 -0700 Subject: [PATCH 8/8] Add dockerignore Signed-off-by: Ryan Friedman --- .dockerignore | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .dockerignore diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..8848192 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.vscode/* +html/* +build/* +install/* +log/* +LICENSE