-
Notifications
You must be signed in to change notification settings - Fork 0
/
noetic.Dockerfile
269 lines (221 loc) · 6.71 KB
/
noetic.Dockerfile
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
##############################################M
# Created from template ros.dockerfile.jinja
# And from althackst/dockerfiles
##############################################
###########################################
# Base image
###########################################
FROM ubuntu:20.04 AS base
ENV DEBIAN_FRONTEND=noninteractive
# Install language
RUN apt-get update && apt-get install -y \
locales \
&& locale-gen en_US.UTF-8 \
&& update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 \
&& rm -rf /var/lib/apt/lists/*
ENV LANG en_US.UTF-8
# Install timezone
RUN ln -fs /usr/share/zoneinfo/EST /etc/localtime \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y tzdata \
&& dpkg-reconfigure --frontend noninteractive tzdata \
&& rm -rf /var/lib/apt/lists/*
# Set timezone
ENV TZ="Canada/Eastern"
RUN date
# Install ROS
RUN apt-get update && apt-get install -y \
curl \
dirmngr \
gnupg2 \
lsb-release \
sudo \
&& sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' \
&& curl -s https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | apt-key add - \
&& apt-get update && apt-get install -y \
ros-noetic-ros-base \
&& rm -rf /var/lib/apt/lists/*
# Install ros tools
RUN apt-get update && apt-get install -y \
apt-utils \
build-essential \
gcc \
g++ \
clang \
make \
bash-completion \
cmake \
git \
pylint \
python3-catkin-tools \
python3-argcomplete \
python3-colcon-common-extensions \
python3-pip \
python3-rosdep \
python3-vcstool \
python3-rosbag \
ros-sensor-msgs \
wget \
clangd \
python3-pip \
python3-autopep8
# Setup environment
ENV LD_LIBRARY_PATH=/opt/ros/noetic/lib
ENV ROS_DISTRO=noetic
ENV ROS_PYTHON_VERSION=3
ENV ROS_VERSION=1
ENV PATH=/opt/ros/noetic/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV PYTHONPATH=/opt/ros/noetic/lib/python3/dist-packages
ARG USERNAME=ros
ARG WORKSPACE=ros_ws
# Create workspace directory
RUN mkdir -p /home/$USERNAME/$WORKSPACE/
# Initialize, update, and install rosdep
RUN cd /home/$USERNAME/$WORKSPACE \
&& rosdep init \
&& rosdep update
# Initialize catkin workspace
RUN cd /home/$USERNAME/$WORKSPACE \
&& catkin config --merge-devel \
&& catkin init
###########################################
# Develop image
###########################################
FROM base AS dev
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
dialog \
gdb \
zsh \
neovim \
# Install ros distro testing packages
&& rm -rf /var/lib/apt/lists/* \
&& rosdep init || echo "rosdep already initialized" \
# Update pydocstyle
&& pip install --upgrade pydocstyle
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# Create a non-root user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \
# [Optional] Add sudo support for the non-root user
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\
&& chmod 0440 /etc/sudoers.d/$USERNAME \
# Cleanup
&& rm -rf /var/lib/apt/lists/* \
&& echo "source /usr/share/bash-completion/completions/git" >> /home/$USERNAME/.bashrc \
&& echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.bash ]; then source /opt/ros/${ROS_DISTRO}/setup.bash; fi" >> /home/$USERNAME/.bashrc
# Create a development directory
RUN mkdir -p /home/$USERNAME/Dev
# Install latest stable eigen release
RUN git config --global http.sslverify false \
&& git clone https://gitlab.com/libeigen/eigen.git /home/$USERNAME/Dev/external/eigen \
&& cd /home/$USERNAME/Dev/external/eigen \
&& mkdir build && cd build \
&& cmake .. \
&& sudo make install \
&& git config --global http.sslverify false
# Install fzf
RUN git clone https://github.com/junegunn/fzf.git /home/$USERNAME/Dev/external/fzf \
&& cd /home/$USERNAME/Dev/external/fzf \
&& ./install --all
# Clone custom workstation setup and setup packages
RUN git clone https://github.com/aalbaali/workstation_setup.git /home/$USERNAME/Dev/workstation_setup -b nvchad \
&& cd /home/$USERNAME/Dev/workstation_setup && \
&& sudo ./scripts/install_packages.sh \
&& rm /home/$USERNAME/.bashrc \
&& rm /home/$USERNAME/.zshrc \
&& if [ -f /home/$USERNAME/.gitconfig ]; then rm /home/$USERNAME/.gitconfig; fi \
&& ./scripts/post_install_setup.sh \
--zsh \
--zsh-setup \
--bash \
--functions \
--git \
--nvim \
--nvim-setup \
--clang_format \
--gdb \
--tmux \
--tmux-setup
# Add ROS sourcing to zshrc
RUN echo "if [ -f /opt/ros/${ROS_DISTRO}/setup.zsh ]; then source /opt/ros/${ROS_DISTRO}/setup.zsh; fi" >> /home/$USERNAME/.zshrc
ENV DEBIAN_FRONTEND=
CMD ["zsh"]
###########################################
# OpenCV
###########################################
FROM dev AS opencv
ARG USERNAME
ARG USER_UID
ARG USER_GID
ENV DEBIAN_FRONTEND=noninteractive
RUN sudo apt-get update \
&& sudo apt-get install -y \
libopencv-dev \
python3-opencv \
&& sudo rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND=
USER $USERNAME
CMD ["zsh"]
###########################################
# Full image
###########################################
FROM opencv AS full
ARG USERNAME
ARG USER_UID
ARG USER_GID
ENV DEBIAN_FRONTEND=noninteractive
# Install the full release
RUN sudo apt-get update \
&& sudo apt-get install -y \
ros-${ROS_DISTRO}-desktop \
&& sudo rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND=
USER $USERNAME
CMD ["zsh"]
###########################################
# Full+Gazebo image
###########################################
FROM full AS gazebo
ARG USERNAME
ARG USER_UID
ARG USER_GID
ARG WORKSPACE
ENV DEBIAN_FRONTEND=noninteractive
# Install gazebo
RUN sudo apt-get update \
&& sudo apt-get install -y \
ros-${ROS_DISTRO}-gazebo* \
&& sudo rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND=
USER $USERNAME
CMD ["zsh"]
###########################################
# Full+Gazebo+Nvidia image
###########################################
FROM gazebo AS gazebo-nvidia
ARG USERNAME
ARG USER_UID
ARG USER_GID
################
# Expose the nvidia driver to allow opengl
# Dependencies for glvnd and X11.
################
RUN sudo apt-get update \
&& sudo apt-get install -y -qq --no-install-recommends \
libglvnd0 \
libgl1 \
libglx0 \
libegl1 \
libxext6 \
libx11-6
# Env vars for the nvidia-container-runtime.
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES graphics,utility,compute
ENV QT_X11_NO_MITSHM 1
USER $USERNAME
CMD ["zsh"]