-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile.vnc
235 lines (205 loc) · 9.6 KB
/
Dockerfile.vnc
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
# Part of the examples from the Parallel and High Performance Computing
# Robey and Zamora, Manning Publications
# https://github.com/EssentialsofParallelComputing/Chapter3
#
# Builds a base Docker image for Ubuntu with X Windows and VNC support.
#
# The built image can be found at:
#
# https://hub.docker.com/r/essentialsofparallelcomputing/chapter3
#
# Author:
# Bob Robey <[email protected]>
#
# Derived from version at https://hub.docker.com/r/x11vnc/desktop
# Author: Xiangmin Jiao <[email protected]>
FROM ubuntu:20.04 AS builder
LABEL maintainer Bob Robey <[email protected]>
ARG DOCKER_LANG=en_US
ARG DOCKER_TIMEZONE=America/Denver
WORKDIR /tmp
RUN apt-get -qq update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -qq install -y locales tzdata && \
apt-get clean && rm -rf /var/lib/apt/lists/*
ENV LANG=$DOCKER_LANG.UTF-8 \
LANGUAGE=$DOCKER_LANG:UTF-8
RUN ln -fs /usr/share/zoneinfo/$DOCKER_TIMEZONE /etc/localtime && \
locale-gen $LANG && update-locale LANG=$LANG && \
dpkg-reconfigure -f noninteractive locales tzdata
ENV LC_ALL=$DOCKER_LANG.UTF-8
# Install some required system tools and packages for X Windows and ssh
# Also remove the message regarding unminimize
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
apt-utils apt-file && \
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
curl less vim psmisc runit apt-transport-https ca-certificates \
software-properties-common man sudo rsync tar net-tools gpg-agent \
inetutils-ping csh tcsh zsh build-essential libssl-dev git dos2unix dbus-x11 \
\
openssh-server \
python python3 python3-distutils python3-tk python3-dbus \
\
xserver-xorg-video-dummy \
lxde \
x11-xserver-utils \
xterm \
gnome-themes-standard \
gtk2-engines-pixbuf gtk2-engines-murrine \
libcanberra-gtk-module libcanberra-gtk3-module \
ttf-ubuntu-font-family \
xfonts-base xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic \
libopengl0 mesa-utils libglu1-mesa libgl1-mesa-dri libjpeg8 libjpeg62 \
xauth \
x11vnc \
libz-dev libssl-dev \
\
firefox \
evince texlive-extra-utils && \
chmod 755 /usr/local/share/zsh/site-functions && \
apt-get -y autoremove && \
ssh-keygen -A && \
ln -s -f /lib64/ld-linux-x86-64.so.2 /lib64/ld-lsb-x86-64.so && \
perl -p -i -e 's/#?X11Forwarding\s+\w+/X11Forwarding yes/g; \
s/#?X11UseLocalhost\s+\w+/X11UseLocalhost no/g; \
s/#?PasswordAuthentication\s+\w+/PasswordAuthentication no/g; \
s/#?PermitEmptyPasswords\s+\w+/PermitEmptyPasswords no/g' \
/etc/ssh/sshd_config && \
rm -f /etc/update-motd.d/??-unminimize && \
rm -f /etc/xdg/autostart/lxpolkit.desktop && \
chmod a-x /usr/bin/lxpolkit
# libssl-dev zlib \
# Install websokify and noVNC
RUN curl -O https://bootstrap.pypa.io/get-pip.py && \
python2 get-pip.py && \
pip2 install --no-cache-dir \
setuptools && \
pip2 install -U https://github.com/novnc/websockify/archive/60acf3c.tar.gz && \
mkdir /usr/local/noVNC && \
curl -s -L https://github.com/x11vnc/noVNC/archive/master.tar.gz | \
tar zxf - -C /usr/local/noVNC --strip-components 1 && \
rm -rf /tmp/* /var/tmp/*
# Install x11vnc from source
# Install X-related to compile x11vnc from source code.
# https://bugs.launchpad.net/ubuntu/+source/x11vnc/+bug/1686084
# Also, fix issue with Shift-Tab not working
# https://askubuntu.com/questions/839842/vnc-pressing-shift-tab-tab-only
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get install -y libxtst-dev libssl-dev libjpeg-dev && \
\
mkdir -p /tmp/x11vnc-0.9.14 && \
curl -s -L http://x11vnc.sourceforge.net/dev/x11vnc-0.9.14-dev.tar.gz | \
tar zxf - -C /tmp/x11vnc-0.9.14 --strip-components 1 && \
cd /tmp/x11vnc-0.9.14 && \
./configure --prefix=/usr/local CFLAGS='-O2 -fno-stack-protector -Wall' && \
make && \
make install && \
perl -e 's/,\s*ISO_Left_Tab//g' -p -i /usr/share/X11/xkb/symbols/pc && \
apt-get -y remove libxtst-dev libssl-dev libjpeg-dev && \
apt-get -y autoremove && \
ldconfig
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive \
apt-get -qq install -y cmake git gcc g++ gfortran wget gnupg-agent \
2to3 python3-pip python3-matplotlib python3-numpy jupyter gnuplot-nox \
valgrind kcachegrind graphviz kmod gv xterm x11-apps evince imagemagick \
mpich libmpich-dev \
openmpi-bin openmpi-doc libopenmpi-dev && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# likwid installed manually in container because msr is not accessible
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3 30 \
--slave /usr/bin/pip pip /usr/bin/pip3
# Installing latest GCC compiler (version 10)
RUN apt-get -qq update && \
apt-get -qq install -y gcc-10 g++-10 gfortran-10 && \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-9 80 \
--slave /usr/bin/g++ g++ /usr/bin/g++-9 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-9 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-9 && \
update-alternatives \
--install /usr/bin/gcc gcc /usr/bin/gcc-10 90 \
--slave /usr/bin/g++ g++ /usr/bin/g++-10 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-10 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-10 && \
chmod u+s /usr/bin/update-alternatives
# Installing Intel compilers since they give the best vectorization among compiler vendors
# Also installing Intel Advisor to look at vectorization performance
RUN wget -q https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
RUN apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
RUN rm -f GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
RUN echo "deb https://apt.repos.intel.com/oneapi all main" >> /etc/apt/sources.list.d/oneAPI.list
RUN echo "deb [trusted=yes arch=amd64] https://repositories.intel.com/graphics/ubuntu bionic main" >> /etc/apt/sources.list.d/intel-graphics.list
RUN apt-get -qq update && \
apt-get -qq install -y \
intel-hpckit-getting-started \
intel-oneapi-common-vars \
intel-oneapi-common-licensing \
intel-oneapi-dev-utilities \
intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic \
intel-oneapi-ifort \
intel-oneapi-advisor && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Needed libraries for Intel Advisor graphics user interface
RUN apt-get -qq update && \
apt-get -qq install -y libgtk2.0-0 libxxf86vm1 libsm6 libnss3 libnss3 libx11-xcb1 libxtst6 \
libasound2 libatk-bridge2.0-0 && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Changing config to install in /usr and to use perf events instead of access daemons to
# try and get around permission limitations in a Docker container
RUN update-alternatives --set gcc /usr/bin/gcc-9
RUN wget --no-verbose http://ftp.fau.de/pub/likwid/likwid-5.0.1.tar.gz && tar -xzf likwid-5.0.1.tar.gz && \
cd likwid-5.0.1 && sed -i -e '/ACCESSMODE/s!accessdaemon!perf_event!' \
-e '/PREFIX/s!/usr/local!/usr!' -e '/BUILDFREQ/s/true/false/' config.mk && \
make && make install && cd .. && rm -rf likwid-5.0.1
RUN update-alternatives --set gcc /usr/bin/gcc-10
#RUN sysctl -w kernel.perf_event_paranoid=-1
########################################################
# Customization for user and location
########################################################
# Set up user so that we do not run as root in DOCKER
ENV DOCKER_USER=chapter3 \
DOCKER_UID=9999 \
DOCKER_GID=9999 \
DOCKER_SHELL=/bin/zsh
ENV DOCKER_GROUP=$DOCKER_USER \
DOCKER_HOME=/home/$DOCKER_USER \
SHELL=$DOCKER_SHELL
# Change the default timezone to $DOCKER_TIMEZONE
# Run ldconfig so that /usr/local/lib etc. are in the default
# search path for dynamic linker
RUN groupadd -g $DOCKER_GID $DOCKER_GROUP && \
useradd -m -u $DOCKER_UID -g $DOCKER_GID -s $DOCKER_SHELL -G sudo $DOCKER_USER && \
echo "$DOCKER_USER:"`openssl rand -base64 12` | chpasswd && \
echo "$DOCKER_USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers && \
echo "$DOCKER_TIMEZONE" > /etc/timezone && \
ln -s -f /usr/share/zoneinfo/$DOCKER_TIMEZONE /etc/localtime
ADD image/etc /etc
ADD image/usr /usr
ADD image/sbin /sbin
ADD image/home $DOCKER_HOME
RUN mkdir -p $DOCKER_HOME/.config/mozilla && \
ln -s -f .config/mozilla $DOCKER_HOME/.mozilla && \
touch $DOCKER_HOME/.sudo_as_admin_successful && \
mkdir -p $DOCKER_HOME/shared && \
mkdir -p $DOCKER_HOME/.ssh && \
mkdir -p $DOCKER_HOME/.log && touch $DOCKER_HOME/.log/vnc.log && \
chown -R $DOCKER_USER:$DOCKER_GROUP $DOCKER_HOME
WORKDIR $DOCKER_HOME
USER $DOCKER_USER
ENV LANG=$DOCKER_LANG.UTF-8
ENV PATH=${PATH}:/opt/intel/oneapi/advisor/latest/bin64
ENV PATH=${PATH}:/opt/intel/oneapi/compiler/latest/linux/bin/intel64
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/intel/oneapi/compiler/latest/linux/compiler/lib/intel64_lin
ENV LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/intel/oneapi/compiler/latest/linux/lib
ENV DISPLAY=:0
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=display,graphics,utility
RUN git clone --recursive https://github.com/essentialsofparallelcomputing/Chapter3.git
ENV DOCKER_CMD=start_vnc
USER root
ENTRYPOINT ["/sbin/my_init", "--quiet", "--", "/sbin/setuser", "chapter3"]
CMD ["$DOCKER_CMD"]