-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.simulation
73 lines (64 loc) · 2.82 KB
/
Dockerfile.simulation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
ARG ROS_DISTRO=humble
ARG PREFIX=
FROM husarnet/ros:${PREFIX}${ROS_DISTRO}-ros-core
ARG PREFIX
# select bash as default shell
SHELL ["/bin/bash", "-c"]
ENV IGNITION_VERSION fortress
ENV HUSARION_ROS_BUILD simulation
WORKDIR /ros2_ws
COPY ./healthcheck.cpp /
# install everything needed
RUN MYDISTRO=${PREFIX:-ros}; MYDISTRO=${MYDISTRO//-/} && \
apt-get update --fix-missing && apt-get install -y \
python3-pip \
python3-colcon-common-extensions \
python3-rosdep \
python3-vcstool \
ros-$ROS_DISTRO-teleop-twist-keyboard \
git && \
apt-get upgrade -y && \
# build & install ROSbot XL packages
source "/opt/$MYDISTRO/$ROS_DISTRO/setup.bash" && \
git clone https://github.com/husarion/rosbot_xl_ros.git /ros2_ws/src && \
vcs import src < src/rosbot_xl/rosbot_xl_hardware.repos && \
vcs import src < src/rosbot_xl/rosbot_xl_simulation.repos && \
# without this line (using vulcanexus base image) rosdep init throws error: "ERROR: default sources list file already exists:"
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 && \
# Create healthcheck package
cd src/ && \
ros2 pkg create healthcheck_pkg --build-type ament_cmake --dependencies rclcpp nav_msgs && \
sed -i '/find_package(nav_msgs REQUIRED)/a \
add_executable(healthcheck_node src/healthcheck.cpp)\n \
ament_target_dependencies(healthcheck_node rclcpp nav_msgs)\n \
install(TARGETS healthcheck_node DESTINATION lib/${PROJECT_NAME})' \
/ros2_ws/src/healthcheck_pkg/CMakeLists.txt && \
mv /healthcheck.cpp /ros2_ws/src/healthcheck_pkg/src/ && \
cd .. && \
# Build
colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release && \
# Save version
echo $(cat /ros2_ws/src/rosbot_xl_gazebo/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') > /version.txt && \
# Size optimalization
rm -rf build log src && \
export SUDO_FORCE_REMOVE=yes && \
apt-get remove -y \
python3-pip \
python3-colcon-common-extensions \
python3-rosdep \
python3-vcstool \
git && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Run healthcheck in background
RUN entrypoint_file=$(if [ -f "/ros_entrypoint.sh" ]; then echo "/ros_entrypoint.sh"; else echo "/vulcanexus_entrypoint.sh"; fi) && \
sed -i '/test -f "\/ros2_ws\/install\/setup.bash" && source "\/ros2_ws\/install\/setup.bash"/a \
ros2 run healthcheck_pkg healthcheck_node &' \
$entrypoint_file
COPY ./healthcheck.sh /
HEALTHCHECK --interval=2s --timeout=1s --start-period=30s --retries=1 \
CMD ["/healthcheck.sh"]