Skip to content

Commit

Permalink
Merge pull request #1 from Ryanf55/multistage-docker-and-cache-fixing
Browse files Browse the repository at this point in the history
Add multistage, fix cache, add rviz dep
  • Loading branch information
avcuenes authored Jan 20, 2024
2 parents 5412dfe + 732e49b commit ae21ad9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 21 deletions.
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.vscode/*
html/*
build/*
install/*
log/*
LICENSE
35 changes: 19 additions & 16 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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




4 changes: 3 additions & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
<depend>libgdal-dev</depend>
<depend>rclcpp</depend>
<depend>yaml_cpp_vendor</depend>
<exec_depend>ros2launch</exec_depend>

<exec_depend>grid_map_rviz_plugin</exec_depend>
<exec_depend>ros2launch</exec_depend>
<exec_depend>rviz2</exec_depend>

<export>
<build_type>ament_cmake</build_type>
Expand Down

0 comments on commit ae21ad9

Please sign in to comment.