-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.vnc
More file actions
209 lines (183 loc) · 8.07 KB
/
Dockerfile.vnc
File metadata and controls
209 lines (183 loc) · 8.07 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
# Part of the examples from the Parallel and High Performance Computing
# Robey and Zamora, Manning Publications
# https://github.com/EssentialsofParallelComputing/Chapter13
#
# 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/chapter13
#
# Author:
# Bob Robey <brobey@earthlink.net>
#
# Derived from version at https://hub.docker.com/r/x11vnc/desktop
# Author: Xiangmin Jiao <xmjiao@gmail.com>
FROM ubuntu:20.04 AS builder
LABEL maintainer Bob Robey <brobey@earthlink.net>
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 vim gcc g++ gfortran software-properties-common \
wget gnupg-agent libglu1-mesa-dev freeglut3-dev mesa-common-dev cmake \
imagemagick libmagickwand-dev libnuma1 && \
apt-get clean && rm -rf /var/lib/apt/lists/*
# Installing latest GCC compiler (version 10)
RUN apt-get -qq update && \
apt-get -qq install -y gcc-8 g++-8 gfortran-8 \
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-8 90 \
--slave /usr/bin/g++ g++ /usr/bin/g++-8 \
--slave /usr/bin/gfortran gfortran /usr/bin/gfortran-8 \
--slave /usr/bin/gcov gcov /usr/bin/gcov-8 && \
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 70 \
--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
# Nvidia GPU software for computation
RUN wget --no-verbose https://developer.download.nvidia.com/hpc-sdk/20.9/nvhpc-20-9_20.9_amd64.deb
RUN wget --no-verbose https://developer.download.nvidia.com/hpc-sdk/20.9/nvhpc-2020_20.9_amd64.deb
RUN DEBIAN_FRONTEND=noninteractive \
apt-get install -y ./nvhpc-20-9_20.9_amd64.deb ./nvhpc-2020_20.9_amd64.deb && \
apt-get clean && rm -rf /var/lib/apt/lists/*
########################################################
# Customization for user and location
########################################################
# Set up user so that we do not run as root in DOCKER
ENV DOCKER_USER=chapter13 \
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
RUN usermod -a -G video chapter13
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 NVARCH=Linux_x86_64
ENV NVCOMPILERS=/opt/nvidia/hpc_sdk
ENV MANPATH=$MANPATH:$NVCOMPILERS/$NVARCH/20.9/compilers/man
ENV PATH=$NVCOMPILERS/$NVARCH/20.9/compilers/bin:$PATH
ENV CC=pgcc
ENV DISPLAY=:0
ENV NVIDIA_VISIBLE_DEVICES=all
ENV NVIDIA_DRIVER_CAPABILITIES=display,graphics,utility,compute
RUN git clone --recursive https://github.com/essentialsofparallelcomputing/Chapter13.git
ENV DOCKER_CMD=start_vnc
USER root
ENTRYPOINT ["/sbin/my_init", "--quiet", "--", "/sbin/setuser", "chapter13"]
CMD ["$DOCKER_CMD"]