From 06c551e3c8c6aadb5758ae9da60b95ec42e09d33 Mon Sep 17 00:00:00 2001 From: rafal-gorecki Date: Mon, 4 Dec 2023 16:17:31 +0100 Subject: [PATCH] update --- Dockerfile | 63 ++++++++++++++++++++---------------------------------- 1 file changed, 23 insertions(+), 40 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8d2fd86..1b1823e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,15 @@ -ARG ROS_DISTRO=humble +ARG ROS_DISTRO=iron ARG PREFIX= -### BUILD IMAGE ### -FROM husarnet/ros:${PREFIX}${ROS_DISTRO}-ros-base AS build +FROM husarnet/ros:${PREFIX}${ROS_DISTRO}-ros-core -RUN apt update && apt install -y \ - ros-$ROS_DISTRO-nav2-msgs +ENV SLAM_MODE=navigation +ENV PREFIX_ENV=$PREFIX -# Create healthcheck package WORKDIR /ros2_ws +COPY ./healthcheck /healthcheck + # Install everything needed RUN MYDISTRO=${PREFIX:-ros}; MYDISTRO=${MYDISTRO//-/} && \ apt-get update --fix-missing && apt-get install -y \ @@ -23,8 +23,10 @@ RUN MYDISTRO=${PREFIX:-ros}; MYDISTRO=${MYDISTRO//-/} && \ rm -rf /etc/ros/rosdep/sources.list.d/20-default.list && \ rosdep init && \ rosdep update --rosdistro $ROS_DISTRO && \ - rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y&& cd src/ && \ - source /opt/ros/$ROS_DISTRO/setup.bash && \ + rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y && \ + # Create healthcheck package + cd src/ && \ + source "/opt/$MYDISTRO/$ROS_DISTRO/setup.bash" && \ ros2 pkg create healthcheck_pkg --build-type ament_cmake --dependencies rclcpp lifecycle_msgs nav2_msgs && \ sed -i '/find_package(nav2_msgs REQUIRED)/a \ add_executable(healthcheck_localization src/healthcheck_localization.cpp)\n \ @@ -38,49 +40,30 @@ RUN MYDISTRO=${PREFIX:-ros}; MYDISTRO=${MYDISTRO//-/} && \ healthcheck_navigation \ healthcheck_slam \ DESTINATION lib/${PROJECT_NAME})' \ - /ros2_ws/src/healthcheck_pkg/CMakeLists.txt - -COPY ./healthcheck /ros2_ws/src/healthcheck_pkg/src - -# Build -RUN source /opt/ros/$ROS_DISTRO/setup.bash && \ - colcon build --event-handlers console_direct+ --cmake-args -DCMAKE_BUILD_TYPE=Release - -### RUNTIME IMAGE ### -FROM husarnet/ros:${PREFIX}${ROS_DISTRO}-ros-core - -ARG PREFIX -ENV SLAM_MODE=navigation -ENV PREFIX_ENV=$PREFIX - -WORKDIR /ros2_ws - -RUN apt update && apt upgrade -y && apt install -y \ - ros-$ROS_DISTRO-navigation2 \ - ros-$ROS_DISTRO-nav2-bringup \ - ros-$ROS_DISTRO-pointcloud-to-laserscan && \ - mkdir /maps && \ + /ros2_ws/src/healthcheck_pkg/CMakeLists.txt && \ + mv /healthcheck/* /ros2_ws/src/healthcheck_pkg/src/ && \ + rm -r /healthcheck && \ + cd .. && \ + # Build + colcon build && \ + # Make the image smaller + export SUDO_FORCE_REMOVE=yes && \ + apt-get remove -y \ + ros-dev-tools && \ apt-get autoremove -y && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* COPY ./nav2_params /nav2_params -COPY --from=build /ros2_ws/install /ros2_ws/install RUN echo $(dpkg -s ros-$ROS_DISTRO-navigation2 | grep 'Version' | sed -r 's/Version:\s([0-9]+.[0-9]+.[0-9]+).*/\1/g') > /version.txt -RUN if [ -f "/ros_entrypoint.sh" ]; then \ - sed -i '/test -f "\/ros2_ws\/install\/setup.bash" && source "\/ros2_ws\/install\/setup.bash"/a \ - ros2 run healthcheck_pkg "healthcheck_$SLAM_MODE" &' \ - /ros_entrypoint.sh; \ - else \ - sed -i '/test -f "\/ros2_ws\/install\/setup.bash" && source "\/ros2_ws\/install\/setup.bash"/a \ +RUN sed -i '/test -f "\/ros2_ws\/install\/setup.bash" && source "\/ros2_ws\/install\/setup.bash"/a \ ros2 run healthcheck_pkg "healthcheck_$SLAM_MODE" &' \ - /vulcanexus_entrypoint.sh; \ - fi + /ros_entrypoint.sh COPY ./healthcheck/healthcheck.sh / HEALTHCHECK --interval=7s --timeout=2s --start-period=5s --retries=5 \ CMD ["/healthcheck.sh"] -#tip: gathering logs from healthcheck: docker inspect b39 | jq '.[0].State.Health.Log' +# #tip: gathering logs from healthcheck: docker inspect b39 | jq '.[0].State.Health.Log'