-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
243 lines (195 loc) · 7.98 KB
/
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
FROM nvidia/cudagl:11.4.2-base-ubuntu20.04
ENV DEBIAN_FRONTEND noninteractive
ARG VIRTUALGL_VERSION=3.0.1
ENV ROS_DISTRO=noetic
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
locales \
&& echo "$LANG UTF-8" >> /etc/locale.gen \
&& locale-gen \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# =================================================================
# GNOME Desktop
# =================================================================
RUN apt-get update -y \
&& apt-get install -y \
dbus \
dbus-x11 \
systemd \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& dpkg-divert --local --rename --add /sbin/udevadm \
&& ln -s /bin/true /sbin/udevadm
RUN systemctl disable systemd-resolved
VOLUME ["/sys/fs/cgroup"]
STOPSIGNAL SIGRTMIN+3
CMD [ "/sbin/init" ]
RUN apt-get update -y \
&& apt-get install -y \
ca-certificates \
ubuntu-gnome-desktop \
&& apt-get remove gnome-initial-setup -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# =================================================================
# ROS
# =================================================================
RUN sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
RUN apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
RUN apt-get update && \
apt-get install ros-${ROS_DISTRO}-desktop-full -y
# =================================================================
# VirtualGL
# =================================================================
ARG SOURCEFORGE=https://sourceforge.net/projects
RUN apt-get update && apt-get install -y --no-install-recommends \
curl wget git apt-utils python3-pip less lsof htop gedit gedit-plugins \
libegl1-mesa mesa-utils \
make cmake python x11-xkb-utils xauth xfonts-base xkb-data && \
rm -rf /var/lib/apt/lists/* && \
cd /tmp && \
curl -fsSL \
-O ${SOURCEFORGE}/virtualgl/files/${VIRTUALGL_VERSION}/virtualgl_${VIRTUALGL_VERSION}_amd64.deb && \
dpkg -i *.deb && \
rm -f /tmp/*.deb
ENV PATH ${PATH}:/opt/VirtualGL/bin
# =================================================================
# VNC Server
# =================================================================
# Install TigerVNC server
# NOTE tigervnc because of XKB extension: https://github.com/i3/i3/issues/1983
RUN apt-get update \
&& apt-get install -y tigervnc-common tigervnc-scraping-server tigervnc-standalone-server tigervnc-xorg-extension \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# NOTE logout will stop tigervnc service -> need to manually start (gdm for graphical login is not working)
COPY services/[email protected] /etc/systemd/system/[email protected]
ENV DISPLAY=:2
RUN systemctl enable tigervnc@:2
# =================================================================
# RUN yes | unminimize
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
net-tools \
iputils-ping \
traceroute \
vim \
nano \
gnome-tweaks \
gnome-shell-extensions \
sudo \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Screen recording
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
ffmpeg \
gir1.2-appindicator3-0.1 \
kazam \
vlc \
xdotool \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
COPY system/kazam.desktop /usr/share/applications/kazam.desktop
# ROS dependencies for Robotont
RUN apt-get update -y \
&& apt-get install -y --no-install-recommends \
python3-catkin-tools \
# python3-rosdep \
ros-${ROS_DISTRO}-joy \
ros-${ROS_DISTRO}-teleop-twist-keyboard \
ros-${ROS_DISTRO}-realsense2-description \
ros-${ROS_DISTRO}-serial \
ros-${ROS_DISTRO}-depthimage-to-laserscan \
ros-${ROS_DISTRO}-gmapping \
ros-${ROS_DISTRO}-move-base \
ros-${ROS_DISTRO}-amcl \
ros-${ROS_DISTRO}-map-server
RUN wget -q https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb \
&& dpkg -i google-chrome-stable_current_amd64.deb \
&& rm google-chrome-stable_current_amd64.deb
# Hide update notification:
# =================================================================
RUN echo "Hidden=true" >> /etc/xdg/autostart/update-notifier.desktop
# Set timezone:
RUN rm -rf /etc/localtime
RUN ln -s /usr/share/zoneinfo/Europe/Tallinn /etc/localtime
# Create unprivileged user
# NOTE user hardcoded in tigervnc.service
# NOTE alternative is to use libnss_switch and create user at runtime -> use entrypoint script
ARG UID=1000
ARG USER=kasutaja
ARG PASSWD=remrob
RUN useradd ${USER} -u ${UID} -U -d /home/${USER} -m -s /bin/bash && \
groupadd vglusers && \
usermod -aG vglusers ${USER}
RUN echo "${USER}:${PASSWD}" | chpasswd
ENV USER="${USER}" \
HOME="/home/${USER}"
USER "${USER}"
WORKDIR "/home/${USER}"
# Set up VNC
RUN mkdir -p $HOME/.vnc
COPY system/xstartup $HOME/.vnc/xstartup
# RUN echo "password" | vncpasswd -f >> $HOME/.vnc/passwd && chmod 600 $HOME/.vnc/passwd
SHELL ["/bin/bash", "-c"]
ENV ROS_ROOT=/opt/ros/${ROS_DISTRO}
ENV ROS_PYTHON_VERSION=3
RUN mkdir -p $HOME/catkin_ws/src
WORKDIR $HOME/catkin_ws/src
COPY --chown=1000:1000 src .
WORKDIR $HOME/catkin_ws
RUN source /opt/ros/${ROS_DISTRO}/setup.bash && \
catkin init && \
catkin build
# Save bash history
RUN echo "HISTFILE=$HOME/catkin_ws/.bash_history" >> $HOME/.bashrc
# GNOME customized config
COPY system/user $HOME/.config/dconf/user
COPY img/wallpaper.png $HOME/Pictures/Wallpapers/
# Kazam config (force default h264mp4)
COPY system/kazam.conf $HOME/.config/kazam/kazam.conf
# Camera shortcut
COPY img/camera.png $HOME/Pictures/camera.png
COPY system/cam.desktop $HOME/.local/share/applications/cam.desktop
# COPY terminal.desktop $HOME/.config/autostart/terminal.desktop
# COPY cam.desktop $HOME/.config/autostart/cam.desktop
COPY scripts/launch_camera.sh $HOME/.launch_camera.sh
COPY scripts/launch_pip.sh $HOME/.launch_pip.sh
#RUN sudo chmod 777 "${HOME}/.config/dconf"
#RUN echo $PASSWD sudo -S chown -R $USER:$USER $HOME
# sudo and VirtualGL compatibility: https://groups.google.com/g/virtualgl-users/c/It-4AmVw6qA (Hide error outputs)
RUN echo "alias sudo='env -u LD_PRELOAD sudo'" >> $HOME/.bashrc
RUN echo "alias ping='env -u LD_PRELOAD ping'" >> $HOME/.bashrc
# This will source the env file with every new terminal instance
RUN echo "source /.env.sh" >> $HOME/.bashrc
RUN echo "source /opt/ros/noetic/setup.bash" >> $HOME/.bashrc
RUN echo "source ${HOME}/catkin_ws/devel/setup.bash" >> $HOME/.bashrc
RUN echo "export ROS_MASTER_URI=http://localhost:11311" >> $HOME/.bashrc
# switch back to root to start systemd
USER root
RUN chown -R $USER:$USER $HOME
EXPOSE 5902
# install chrome PiP extension for auto-start
COPY scripts/chrome_pip_extension.sh $HOME/.ext.sh
RUN bash $HOME/.ext.sh
COPY services/cam_launch.service /etc/systemd/system/cam_launch.service
RUN systemctl enable cam_launch.service
RUN systemctl mask [email protected]
ARG SCRIPTS=$HOME/.scripts
RUN mkdir $SCRIPTS
COPY scripts/welcome_msg.sh $SCRIPTS/welcome_msg.sh
COPY scripts/print_message.sh $SCRIPTS/print_message.sh
COPY services/terminal_launch.service /etc/systemd/system/terminal_launch.service
RUN systemctl enable terminal_launch.service
# RUN mkdir -p /root/.vnc & mkdir -p /root/.config/autostart
# COPY startup.desktop /root/.config/autostart/startup.desktop
# COPY xorg.conf /etc/X11/xorg.conf
COPY docker-entrypoint.sh /.docker-entrypoint.sh
COPY scripts/env.sh /.env.sh
# COPY custom.conf /etc/gdm3/custom.conf
# COPY xserverrc /etc/X11/xinit/xserverrc
ENTRYPOINT ["/.docker-entrypoint.sh"]