-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.jetson
165 lines (141 loc) · 5.46 KB
/
Dockerfile.jetson
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
# Reference: https://github.com/stereolabs/zed-ros2-wrapper/tree/master/docker
ARG L4T_MAJOR=35
ARG L4T_MINOR=3
ARG ZED_SDK_MAJOR=4
ARG ZED_SDK_MINOR=0
ARG ROS_DISTRO=foxy
### BUILD IMAGE ###
FROM stereolabs/zed:${ZED_SDK_MAJOR}.${ZED_SDK_MINOR}-devel-l4t-r${L4T_MAJOR}.${L4T_MINOR} AS build
ARG L4T_MAJOR
ARG L4T_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 focal 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-dev-tools \
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 \
build-essential \
python3-colcon-mixin \
python3-flake8-docstrings \
python3-pip \
python3-pytest-cov && \
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
WORKDIR /ros2_ws
RUN source /opt/ros/$ROS_DISTRO/setup.bash && \
colcon build --base-paths src \
--cmake-args ' -DCMAKE_BUILD_TYPE=Release' \
' -DCMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs' \
' -DCMAKE_CXX_FLAGS="-Wl,--allow-shlib-undefined"' \
' --no-warn-unused-cli' && \
rm -rf build log src
### RUNTIME IMAGE ### # Reduction from 6.1GB to 3.9GB
FROM stereolabs/zed:${ZED_SDK_MAJOR}.${ZED_SDK_MINOR}-runtime-l4t-r${L4T_MAJOR}.${L4T_MINOR} AS runtime
ARG L4T_MAJOR
ARG L4T_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 focal 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-dev-tools \
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 \
ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \
build-essential \
curl \
python3-colcon-mixin \
python3-flake8-docstrings \
python3-pip \
python3-pytest-cov && \
pip3 install \
argcomplete \
numpy \
empy \
lark && \
rm -rf /var/lib/apt/lists/*
# Check dependencies
COPY --from=build /ros2_ws /ros2_ws
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/*
# Source workspace when docker exec -it <container> bash
RUN test -f "/ros2_ws/install/setup.bash" && echo "source /ros2_ws/install/setup.bash" >> /etc/bash.bashrc
# 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"]
# Download Husarnet
ARG TARGETARCH
ARG HUSARNET_DDS_RELEASE="v1.3.5"
ENV HUSARNET_DDS_DEBUG=FALSE
RUN curl -L https://github.com/husarnet/husarnet-dds/releases/download/${HUSARNET_DDS_RELEASE}/husarnet-dds-linux-${TARGETARCH} -o /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"]