-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
113 lines (89 loc) · 3.59 KB
/
Dockerfile
File metadata and controls
113 lines (89 loc) · 3.59 KB
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
FROM ros:humble-ros-base-jammy AS base
ENV NEBULA_VERSION=0.2.15.3
# Install basic dev tools (And clean apt cache afterwards)
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
apt-get -y --quiet --no-install-recommends install \
wget \
# Install Zenoh ROS2 RMW
ros-"$ROS_DISTRO"-rmw-zenoh-cpp \
&& rm -rf /var/lib/apt/lists/*
# Setup ROS workspace folder
ENV ROS_WS=/opt/ros_ws
WORKDIR $ROS_WS
# Setup Zenoh ROS2 RMW
ENV RMW_IMPLEMENTATION=rmw_zenoh_cpp
# Enable ROS log colorised output
ENV RCUTILS_COLORIZED_OUTPUT=1
COPY ./entrypoint.sh /
# Download and setup Nebula Driver
WORKDIR $ROS_WS/src
RUN wget --progress=dot:giga https://github.com/tier4/nebula/archive/refs/tags/v$NEBULA_VERSION.tar.gz \
&& tar -xvzf v$NEBULA_VERSION.tar.gz
WORKDIR $ROS_WS/src/nebula-$NEBULA_VERSION
RUN vcs import < build_depends.repos \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
rosdep install --from-paths . --ignore-src -y -r \
&& rm -rf /var/lib/apt/lists/*
# Source ROS setup for dependencies and build our code
WORKDIR $ROS_WS
RUN . /opt/ros/"$ROS_DISTRO"/setup.sh \
&& colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
# -----------------------------------------------------------------------
FROM base AS prebuilt
# Copy nebula artifacts/binaries from base to avoid re-compiling them
RUN mkdir -p "$ROS_WS"/install
COPY --from=base $ROS_WS/install "$ROS_WS"/install
RUN mkdir -p "$ROS_WS"/build
COPY --from=base "$ROS_WS"/build "$ROS_WS"/build
# Import av_lidar_launch
COPY ./ "$ROS_WS"/src/av_lidar_launch
# Source ROS setup for dependencies and build our code
RUN . /opt/ros/"$ROS_DISTRO"/setup.sh \
&& colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
# -----------------------------------------------------------------------
FROM base AS dev
# Copy prebuild nebula ros driver from base
RUN mkdir -p "$ROS_WS"/install
COPY --from=base "$ROS_WS"/install "$ROS_WS"/install
RUN mkdir -p "$ROS_WS"/build
COPY --from=base "$ROS_WS"/build "$ROS_WS"/build
RUN mkdir -p "$ROS_WS"/log
COPY --from=base "$ROS_WS"/log "$ROS_WS"/log
# Install basic dev tools (And clean apt cache afterwards)
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive \
apt-get -y --quiet --no-install-recommends install \
# Command-line editor
nano \
# Ping network tools
inetutils-ping \
# Bash auto-completion for convenience
bash-completion \
# RVIZ
ros-"$ROS_DISTRO"-rviz2 \
&& rm -rf /var/lib/apt/lists/*
# Add sourcing local workspace command to bashrc for
# convenience when running interactively
RUN echo "source /opt/ros/$ROS_DISTRO/setup.bash" >> /etc/bash.bashrc && \
# Add colcon build alias for convenience
echo 'alias colcon_build="colcon build --symlink-install \
--cmake-args -DCMAKE_BUILD_TYPE=Release && \
source install/setup.bash"' >> /etc/bash.bashrc
# Enter bash for development
# CMD ["bash"]
ENTRYPOINT [ "/entrypoint.sh" ]
# -----------------------------------------------------------------------
FROM base AS runtime
# Copy artifacts/binaries from prebuilt
COPY --from=prebuilt "$ROS_WS"/src "$ROS_WS"/src
COPY --from=prebuilt "$ROS_WS"/install "$ROS_WS"/install
COPY --from=prebuilt "$ROS_WS"/build "$ROS_WS"/build
# Add command to docker entrypoint to source newly compiled
# code when running docker container
RUN sed --in-place --expression \
"\$isource \"$ROS_WS/install/setup.bash\" " \
/ros_entrypoint.sh
# launch ros package
CMD ["ros2", "launch", "av_lidar_launch", "all_lidars.launch.xml"]