forked from clydemcqueen/orca5
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
285 lines (237 loc) · 8.47 KB
/
Dockerfile
File metadata and controls
285 lines (237 loc) · 8.47 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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
###############################
# base stage, common to all targets
###############################
FROM osrf/ros:jazzy-desktop AS base
ARG USERNAME=orca5
ARG USER_UID=1001
ARG USER_GID=$USER_UID
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get upgrade -y
RUN apt-get update \
&& apt-get -y --quiet --no-install-recommends install \
bash-completion \
build-essential \
git \
gnupg \
iputils-ping \
lsb-release \
libglvnd0 \
libgl1 \
libglx0 \
libegl1 \
libxext6 \
libx11-6 \
python3-venv \
software-properties-common \
sudo \
wget \
vim \
libjpeg-dev \
libpng-dev \
catch2 \
libavcodec-dev \
libavutil-dev \
libavformat-dev \
libswscale-dev \
libavdevice-dev \
libc++-dev \
libepoxy-dev \
libglew-dev \
libeigen3-dev \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
# Required for ardupilot install, but generally a good idea
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME \
&& echo "\n# Added by orca5 Dockerfile:" >> /home/$USERNAME/.bashrc \
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc
USER root
WORKDIR /tmp/
RUN git clone --recursive -b v0.9.2 https://github.com/stevenlovegrove/Pangolin.git && \
cd Pangolin && \
# apt update && \
# ./scripts/install_prerequisites.sh recommended && \
mkdir build && \
cd build && \
cmake .. -DCMAKE_BUILD_TYPE=Release && \
make -j$(nproc) && \
make install && \
cd .. && \
rm -rf build
# Switch to our new user
USER $USERNAME
# install-prereqs-ubuntu.sh looks at $USER
ENV USER=$USERNAME
WORKDIR /home/$USERNAME
RUN git clone https://github.com/Projeto-Voris/ORB-SLAM3.git ORB_SLAM3
WORKDIR /home/$USER/ORB_SLAM3
RUN chmod +x build.sh &&\
./build.sh
# Create colcon workspace and the mount point for orca5
WORKDIR /home/$USERNAME
RUN mkdir -p colcon_ws/src/orca5
# Get common repos
WORKDIR /home/$USERNAME/colcon_ws/src
COPY --chown=$USER_UID:$USER_GID common.repos orca5
RUN vcs import --recursive < orca5/common.repos
# Copy orca5 package.xml files
WORKDIR /home/$USERNAME/colcon_ws
COPY --chown=$USER_UID:$USER_GID orca_bridge/package.xml src/orca5/orca_bridge/
COPY --chown=$USER_UID:$USER_GID orca_bringup/package.xml src/orca5/orca_bringup/
COPY --chown=$USER_UID:$USER_GID orca_msgs/package.xml src/orca5/orca_msgs/
# Run rosdep over all repos
# Fun fact: rosdep will automatically elevate permissions, but apt-get will not, so it requires sudo
WORKDIR /home/$USERNAME/colcon_ws
RUN sudo apt-get update \
&& rosdep update \
&& rosdep install -y --from-paths . --ignore-src
# Do not build orca5 yet
WORKDIR /home/$USERNAME/colcon_ws
RUN touch src/orca5/COLCON_IGNORE
# Build everything so far
WORKDIR /home/$USERNAME/colcon_ws
RUN [ "/bin/bash" , "-c" , "\
source /opt/ros/jazzy/setup.bash \
&& colcon build --event-handlers console_direct+" ]
# Copy orca5 requirements.txt file
WORKDIR /home/$USERNAME/colcon_ws
COPY --chown=$USER_UID:$USER_GID requirements.txt src/orca5/
# Set up the Python environment
WORKDIR /home/$USERNAME/colcon_ws
RUN python3 -m venv venv --system-site-packages \
&& touch venv/COLCON_IGNORE \
&& . venv/bin/activate \
&& pip install -r src/orca5/requirements.txt
# Configure the shell environment
RUN echo "source /home/$USERNAME/colcon_ws/install/setup.bash" >> /home/$USERNAME/.bashrc
# Create a mount point for orca5 source, this will shadow the existing orca5 directory
VOLUME /home/$USERNAME/colcon_ws/src/orca5
###############################
# sim target
###############################
FROM base AS sim
# Switch to root to install stuff
USER root
# Install Gazebo Harmonic for use with ROS2 Jazzy
RUN apt-get update \
&& apt-get -y --quiet --no-install-recommends install ros-jazzy-ros-gz \
&& rm -rf /var/lib/apt/lists/*
# Install ardupilot and ardupilot_gazebo prereqs
RUN apt-get update \
&& apt-get -y --quiet --no-install-recommends install \
python3-pip \
python3-wxgtk4.0 \
rapidjson-dev \
xterm \
libopencv-dev \
libgstreamer1.0-dev \
libgstreamer-plugins-base1.0-dev \
gstreamer1.0-plugins-bad \
gstreamer1.0-libav \
gstreamer1.0-gl \
&& rm -rf /var/lib/apt/lists/*
# Add packages.osrfoundation.org, required by ardupilot_gazebo
RUN curl https://packages.osrfoundation.org/gazebo.gpg --output /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] https://packages.osrfoundation.org/gazebo/ubuntu-stable $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null
# Add OSRF's rosdep rules so that rosdep will find Gazebo Harmonic keys
# Ref https://github.com/ArduPilot/ardupilot_gazebo#Rosdep
RUN wget https://raw.githubusercontent.com/osrf/osrf-rosdep/master/gz/00-gazebo.list -O /etc/ros/rosdep/sources.list.d/00-gazebo.list
# Switch back to new user
USER $USERNAME
# Clone ArduSub code
WORKDIR /home/$USERNAME
RUN git clone https://github.com/ArduPilot/ardupilot.git --recurse-submodules
# && cd ardupilot \
# && git checkout 9eb5dc4
# Install ArduSub prereqs (this also appends to .bashrc)
WORKDIR /home/$USERNAME/ardupilot
ENV SKIP_AP_EXT_ENV=1 SKIP_AP_GRAPHIC_ENV=1 SKIP_AP_COV_ENV=1 SKIP_AP_GIT_CHECK=1
RUN Tools/environment_install/install-prereqs-ubuntu.sh -y
# Build ArduSub
# Note: waf will capture all of the environment variables in ardupilot/.lock-waf_linux_build.
# Any change to enviroment variables will cause a re-build.
# To avoid this call sim_vehicle.py with the "--no-rebuild" option.
WORKDIR /home/$USERNAME/ardupilot
RUN modules/waf/waf-light configure --board sitl \
&& modules/waf/waf-light build --target bin/ardusub
# Build for Gazebo Harmonic, define this before building ardupilot_gazebo
ENV GZ_VERSION=harmonic
# Get sim repos
WORKDIR /home/$USERNAME/colcon_ws/src
COPY --chown=$USER_UID:$USER_GID sim.repos orca5
RUN vcs import --recursive < orca5/sim.repos
RUN tar -xf orbslam3_ros2/orbslam3_ros2/vocabulary/ORBvoc.txt.tar.gz -C src/orbslam3_ros2/orbslam3_ros2/vocabulary
USER root
RUN apt-get update \
&& apt-get -y --quiet --no-install-recommends install \
libgstreamer1.0-dev \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-tools \
gstreamer1.0-x \
libgstreamer-plugins-base1.0-dev \
libunwind-dev \
&& rm -rf /var/lib/apt/lists/*
USER $USERNAME
# Run rosdep over sim repos
WORKDIR /home/$USERNAME/colcon_ws
RUN sudo apt-get update \
&& rosdep update \
&& rosdep install -y --from-paths . --ignore-src
# Build everything so far
WORKDIR /home/$USERNAME/colcon_ws
RUN [ "/bin/bash" , "-c" , "\
source /opt/ros/jazzy/setup.bash \
&& colcon build --packages-select orbslam3_ros2 --symlink-install" ]
RUN [ "/bin/bash" , "-c" , "\
source /opt/ros/jazzy/setup.bash \
&& colcon build --event-handlers console_direct+" ]
# Configure the shell environment
RUN echo "export PATH=\"/home/$USERNAME/ardupilot/build/sitl/bin:\$PATH\"" >> /home/$USERNAME/.bashrc
# Use bash as the default shell
SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["/bin/bash"]
###############################
# hw target (assumes CPU)
###############################
FROM base AS hw
# Switch to root to install stuff
USER root
# Install gscam2 prereqs
RUN apt-get update \
&& apt-get -y --quiet --no-install-recommends install \
libgstreamer1.0-dev \
gstreamer1.0-plugins-base \
gstreamer1.0-plugins-good \
gstreamer1.0-plugins-bad \
gstreamer1.0-plugins-ugly \
gstreamer1.0-libav \
gstreamer1.0-tools \
gstreamer1.0-x \
libgstreamer-plugins-base1.0-dev \
libunwind-dev \
&& rm -rf /var/lib/apt/lists/*
# Switch back to new user
USER $USERNAME
# Get hw repos
WORKDIR /home/$USERNAME/colcon_ws/src
COPY --chown=$USER_UID:$USER_GID hw.repos orca5
RUN vcs import --recursive < orca5/hw.repos
# Run rosdep over hw repos
WORKDIR /home/$USERNAME/colcon_ws
RUN sudo apt-get update \
&& rosdep update \
&& rosdep install -y --from-paths . --ignore-src
# Build everything so far
WORKDIR /home/$USERNAME/colcon_ws
RUN [ "/bin/bash" , "-c" , "\
source /opt/ros/jazzy/setup.bash \
&& colcon build --event-handlers console_direct+" ]
# Use bash as the default shell
SHELL ["/bin/bash", "-c"]
ENTRYPOINT ["/bin/bash"]