-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.desktop
executable file
·177 lines (146 loc) · 5.7 KB
/
Dockerfile.desktop
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Reference: https://github.com/stereolabs/zed-ros2-wrapper/tree/master/docker
ARG UBUNTU_RELEASE_YEAR=22.04
ARG CUDA_MAJOR=11
ARG CUDA_MINOR=8
ARG ZED_SDK_MAJOR=4
ARG ZED_SDK_MINOR=0
ARG ROS_DISTRO=humble
### DOWNLOAD HUSARNET ###
FROM ubuntu:${UBUNTU_RELEASE_YEAR} AS husarnet-dds-getter
ARG TARGETARCH
ARG HUSARNET_DDS_RELEASE="v1.3.5"
ENV HUSARNET_DDS_DEBUG=FALSE
RUN apt update && apt install -y \
curl
RUN curl -L https://github.com/husarnet/husarnet-dds/releases/download/${HUSARNET_DDS_RELEASE}/husarnet-dds-linux-${TARGETARCH} -o /usr/bin/husarnet-dds
### BUILD IMAGE ###
FROM stereolabs/zed:${ZED_SDK_MAJOR}.${ZED_SDK_MINOR}-devel-cuda${CUDA_MAJOR}.${CUDA_MINOR}-ubuntu${UBUNTU_RELEASE_YEAR} AS build
ARG UBUNTU_RELEASE_YEAR
ARG CUDA_MAJOR
ARG CUDA_MINOR
ARG ZED_SDK_MAJOR
ARG ZED_SDK_MINOR
ARG ROS_DISTRO
SHELL ["/bin/bash", "-c"]
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}compute,video,utility
# ROS install
ENV ROS_DISTRO $ROS_DISTRO
RUN echo "deb http://packages.ros.org/ros2/ubuntu jammy main" > /etc/apt/sources.list.d/ros2-latest.list && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 && \
apt-get update && \
apt-get install -y --no-install-recommends \
ros-$ROS_DISTRO-ros-core \
&& rm -rf /var/lib/apt/lists/*
# ZED setup
RUN apt-get update || true && \
apt-get install --no-install-recommends -y \
ros-${ROS_DISTRO}-ros-base \
ros-${ROS_DISTRO}-ament-cmake-clang-format \
ros-${ROS_DISTRO}-image-transport \
ros-${ROS_DISTRO}-image-transport-plugins \
ros-${ROS_DISTRO}-diagnostic-updater \
ros-${ROS_DISTRO}-xacro \
python3-flake8-docstrings \
python3-pip \
python3-pytest-cov \
ros-dev-tools && \
pip3 install \
argcomplete \
numpy \
empy \
lark && \
rm -rf /var/lib/apt/lists/*
# Check dependencies
WORKDIR /ros2_ws
RUN apt-get update && \
git clone --recursive https://github.com/stereolabs/zed-ros2-wrapper.git src/zed-ros2-wrapper && \
source /opt/ros/$ROS_DISTRO/setup.bash && \
rosdep init && \
rosdep update --rosdistro $ROS_DISTRO && \
rosdep install --from-paths src -y -i && \
rm -rf /var/lib/apt/lists/*
# Create health check package
RUN cd src/ && \
source /opt/ros/$ROS_DISTRO/setup.bash && \
ros2 pkg create healthcheck_pkg --build-type ament_cmake --dependencies rclcpp sensor_msgs && \
sed -i '/find_package(sensor_msgs REQUIRED)/a \
add_executable(healthcheck_node src/healthcheck.cpp)\n \
ament_target_dependencies(healthcheck_node rclcpp sensor_msgs)\n \
install(TARGETS healthcheck_node DESTINATION lib/${PROJECT_NAME})' \
/ros2_ws/src/healthcheck_pkg/CMakeLists.txt
COPY ./healthcheck.cpp /ros2_ws/src/healthcheck_pkg/src/
# Build
RUN source /opt/ros/$ROS_DISTRO/setup.bash && \
colcon build --parallel-workers $(nproc) --symlink-install \
--event-handlers console_direct+ --base-paths src \
--cmake-args ' -DCMAKE_BUILD_TYPE=Release' \
' -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs' \
' -DCMAKE_CXX_FLAGS="-Wl,--allow-shlib-undefined"'
### BUILD RUNTIME ### # Reduction from 13.4GB to 8.6GB
FROM stereolabs/zed:${ZED_SDK_MAJOR}.${ZED_SDK_MINOR}-runtime-cuda${CUDA_MAJOR}.${CUDA_MINOR}-ubuntu${UBUNTU_RELEASE_YEAR} AS runtime
COPY --from=build /ros2_ws /ros2_ws
ARG UBUNTU_RELEASE_YEAR
ARG CUDA_MAJOR
ARG CUDA_MINOR
ARG ZED_SDK_MAJOR
ARG ZED_SDK_MINOR
ARG ROS_DISTRO
SHELL ["/bin/bash", "-c"]
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}compute,video,utility
# ROS install
ENV ROS_DISTRO $ROS_DISTRO
RUN echo "deb http://packages.ros.org/ros2/ubuntu jammy main" > /etc/apt/sources.list.d/ros2-latest.list && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 && \
apt-get update && \
apt-get install -y --no-install-recommends \
ros-$ROS_DISTRO-ros-core \
&& rm -rf /var/lib/apt/lists/*
# ZED setup
RUN apt-get update || true && \
apt-get install --no-install-recommends -y \
ros-${ROS_DISTRO}-ros-base \
ros-${ROS_DISTRO}-ament-cmake-clang-format \
ros-${ROS_DISTRO}-image-transport \
ros-${ROS_DISTRO}-image-transport-plugins \
ros-${ROS_DISTRO}-diagnostic-updater \
ros-${ROS_DISTRO}-xacro \
python3-flake8-docstrings \
python3-pip \
python3-pytest-cov \
ros-dev-tools && \
pip3 install \
argcomplete \
numpy \
empy \
lark && \
rm -rf /var/lib/apt/lists/*
# Check dependencies
WORKDIR /ros2_ws
RUN apt-get update && \
source /opt/ros/$ROS_DISTRO/setup.bash && \
rosdep init && \
rosdep update --rosdistro $ROS_DISTRO && \
rosdep install --from-paths src -y -i && \
rm -rf /var/lib/apt/lists/*
# Setup DDS
RUN apt-get update && apt-get install -y \
ros-$ROS_DISTRO-rmw-fastrtps-cpp \
ros-$ROS_DISTRO-rmw-cyclonedds-cpp && \
apt-get upgrade -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
# Git action version
RUN echo $(cat /ros2_ws/src/zed-ros2-wrapper/zed_wrapper/package.xml | grep '<version>' | sed -r 's/.*<version>([0-9]+.[0-9]+.[0-9]+)<\/version>/\1/g') >> /version.txt
COPY ./ros_entrypoint.sh /
COPY ./healthcheck.sh /
HEALTHCHECK --interval=2s --timeout=1s --start-period=20s --retries=1 \
CMD ["/healthcheck.sh"]
# Add Husarnet
COPY --from=husarnet-dds-getter /usr/bin/husarnet-dds /usr/bin/husarnet-dds
RUN chmod +x /usr/bin/husarnet-dds
# Setup environment variables
COPY ./ros_entrypoint.sh /ros_entrypoint.sh
ENTRYPOINT ["/ros_entrypoint.sh"]
CMD ["bash"]