Skip to content

Commit d7132e7

Browse files
committed
2 parents c9b12b3 + 03d93d9 commit d7132e7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2003
-0
lines changed

ubuntu/Dockerfile.18.04.gnome.amd64

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
FROM ubuntu:18.04 as system
2+
3+
RUN sed -i 's#http://archive.ubuntu.com/ubuntu/#mirror://mirrors.ubuntu.com/mirrors.txt#' /etc/apt/sources.list;
4+
5+
# built-in packages
6+
ENV DEBIAN_FRONTEND noninteractive
7+
RUN apt update \
8+
&& apt install -y --no-install-recommends software-properties-common curl apache2-utils \
9+
&& apt update \
10+
&& apt install -y --no-install-recommends --allow-unauthenticated \
11+
supervisor nginx sudo net-tools zenity xz-utils \
12+
dbus-x11 x11-utils alsa-utils \
13+
mesa-utils libgl1-mesa-dri \
14+
&& apt autoclean -y \
15+
&& apt autoremove -y \
16+
&& rm -rf /var/lib/apt/lists/*
17+
# install debs error if combine together
18+
RUN apt update \
19+
&& apt install -y --no-install-recommends --allow-unauthenticated \
20+
xvfb x11vnc \
21+
vim-tiny firefox xfce4-terminal ttf-ubuntu-font-family \
22+
&& apt autoclean -y \
23+
&& apt autoremove -y \
24+
&& rm -rf /var/lib/apt/lists/*
25+
26+
RUN apt update \
27+
&& apt install -y --no-install-recommends --allow-unauthenticated \
28+
ubuntu-desktop \
29+
gnome-panel \
30+
gnome-settings-daemon \
31+
metacity \
32+
nautilus \
33+
gnome-terminal \
34+
&& apt autoclean -y \
35+
&& apt autoremove -y \
36+
&& rm -rf /var/lib/apt/lists/*
37+
38+
# python library (for backend)
39+
COPY rootfs/usr/local/lib/web/backend/requirements.txt /tmp/
40+
RUN apt-get update \
41+
&& dpkg-query -W -f='${Package}\n' > /tmp/a.txt \
42+
&& apt-get install -y python-pip python-dev build-essential \
43+
&& pip install setuptools wheel && pip install -r /tmp/requirements.txt \
44+
&& dpkg-query -W -f='${Package}\n' > /tmp/b.txt \
45+
&& apt-get remove -y `diff --changed-group-format='%>' --unchanged-group-format='' /tmp/a.txt /tmp/b.txt | xargs` \
46+
&& apt-get autoclean -y \
47+
&& apt-get autoremove -y \
48+
&& rm -rf /var/lib/apt/lists/* \
49+
&& rm -rf /var/cache/apt/* /tmp/a.txt /tmp/b.txt
50+
51+
######## Frontend builder
52+
FROM ubuntu:18.04 as builder
53+
54+
RUN sed -i 's#http://archive.ubuntu.com/ubuntu/#mirror://mirrors.ubuntu.com/mirrors.txt#' /etc/apt/sources.list;
55+
56+
57+
RUN apt-get update \
58+
&& apt-get install -y --no-install-recommends curl ca-certificates gnupg patch
59+
60+
# nodejs
61+
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \
62+
&& apt-get install -y nodejs
63+
64+
# yarn
65+
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
66+
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
67+
&& apt-get update \
68+
&& apt-get install -y yarn
69+
70+
# build frontend
71+
COPY web /src/web
72+
RUN cd /src/web \
73+
&& yarn \
74+
&& yarn build
75+
76+
####### Build final image with frontend
77+
FROM system
78+
LABEL maintainer="[email protected]"
79+
80+
COPY --from=builder /src/web/dist/ /usr/local/lib/web/frontend/
81+
COPY rootfs /
82+
RUN cp /etc/supervisor/conf.d/supervisord.gnome /etc/supervisor/conf.d/supervisord.conf
83+
RUN ln -sf /usr/local/lib/web/frontend/static/websockify /usr/local/lib/web/frontend/static/novnc/utils/websockify && \
84+
chmod +x /usr/local/lib/web/frontend/static/websockify/run
85+
86+
RUN ln -sf /usr/local/lib/web/frontend/static/vnc.html /usr/local/lib/web/frontend/static/index.html
87+
RUN ln -sf /usr/local/lib/web/frontend/static/novnc/vnc.html /usr/local/lib/web/frontend/static/novnc/index.html
88+
89+
EXPOSE 80
90+
91+
ENV HOME=/home/work \
92+
SHELL=/bin/bash
93+
HEALTHCHECK --interval=30s --timeout=5s CMD curl --fail http://127.0.0.1:6079/api/health
94+
95+
# Backend.AI specifics
96+
LABEL ai.backend.kernelspec="1" \
97+
ai.backend.envs.corecount="OPENBLAS_NUM_THREADS,OMP_NUM_THREADS,NPROC" \
98+
ai.backend.features="batch query uid-match user-input" \
99+
ai.backend.resource.min.cpu="1" \
100+
ai.backend.resource.min.mem="1g" \
101+
ai.backend.resource.preferred.shmem="512m" \
102+
ai.backend.base-distro="ubuntu18.04" \
103+
ai.backend.runtime-type="app" \
104+
ai.backend.service-ports="gnome:http:80,vnc:http:5900"
105+
106+
COPY ./service-defs /etc/backend.ai/service-defs
107+
COPY policy.yml /etc/backend.ai/jail/policy.yml
108+
COPY bootstrap_gnome.sh /opt/container/bootstrap.sh
109+
WORKDIR /home/work

ubuntu/Dockerfile.18.04.xfce.amd64

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
FROM ubuntu:18.04 as system
2+
3+
RUN sed -i 's#http://archive.ubuntu.com/ubuntu/#mirror://mirrors.ubuntu.com/mirrors.txt#' /etc/apt/sources.list;
4+
5+
# built-in packages
6+
ENV DEBIAN_FRONTEND noninteractive
7+
RUN apt update \
8+
&& apt install -y --no-install-recommends software-properties-common curl apache2-utils \
9+
&& apt update \
10+
&& apt install -y --no-install-recommends --allow-unauthenticated \
11+
supervisor nginx sudo net-tools zenity xz-utils \
12+
dbus-x11 x11-utils alsa-utils \
13+
mesa-utils libgl1-mesa-dri \
14+
&& apt autoclean -y \
15+
&& apt autoremove -y \
16+
&& rm -rf /var/lib/apt/lists/*
17+
# install debs error if combine together
18+
RUN apt update \
19+
&& apt install -y --no-install-recommends --allow-unauthenticated \
20+
xvfb x11vnc \
21+
vim-tiny firefox xfce4-terminal ttf-ubuntu-font-family \
22+
&& apt autoclean -y \
23+
&& apt autoremove -y \
24+
&& rm -rf /var/lib/apt/lists/*
25+
26+
RUN apt update \
27+
&& apt install -y --no-install-recommends --allow-unauthenticated \
28+
xubuntu-desktop \
29+
&& apt autoclean -y \
30+
&& apt autoremove -y \
31+
&& rm -rf /var/lib/apt/lists/*
32+
33+
# python library (for backend)
34+
COPY rootfs/usr/local/lib/web/backend/requirements.txt /tmp/
35+
RUN apt-get update \
36+
&& dpkg-query -W -f='${Package}\n' > /tmp/a.txt \
37+
&& apt-get install -y python-pip python-dev build-essential \
38+
&& pip install setuptools wheel && pip install -r /tmp/requirements.txt \
39+
&& dpkg-query -W -f='${Package}\n' > /tmp/b.txt \
40+
&& apt-get remove -y `diff --changed-group-format='%>' --unchanged-group-format='' /tmp/a.txt /tmp/b.txt | xargs` \
41+
&& apt-get autoclean -y \
42+
&& apt-get autoremove -y \
43+
&& rm -rf /var/lib/apt/lists/* \
44+
&& rm -rf /var/cache/apt/* /tmp/a.txt /tmp/b.txt
45+
46+
######## Frontend builder
47+
FROM ubuntu:18.04 as builder
48+
49+
RUN sed -i 's#http://archive.ubuntu.com/ubuntu/#mirror://mirrors.ubuntu.com/mirrors.txt#' /etc/apt/sources.list;
50+
51+
52+
RUN apt-get update \
53+
&& apt-get install -y --no-install-recommends curl ca-certificates gnupg patch
54+
55+
# nodejs
56+
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \
57+
&& apt-get install -y nodejs
58+
59+
# yarn
60+
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
61+
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list \
62+
&& apt-get update \
63+
&& apt-get install -y yarn
64+
65+
# build frontend
66+
COPY web /src/web
67+
RUN cd /src/web \
68+
&& yarn \
69+
&& yarn build
70+
71+
####### Build final image with frontend
72+
FROM system
73+
LABEL maintainer="[email protected]"
74+
75+
COPY --from=builder /src/web/dist/ /usr/local/lib/web/frontend/
76+
COPY rootfs /
77+
RUN cp /etc/supervisor/conf.d/supervisord.xfce /etc/supervisor/conf.d/supervisord.conf
78+
RUN ln -sf /usr/local/lib/web/frontend/static/websockify /usr/local/lib/web/frontend/static/novnc/utils/websockify && \
79+
chmod +x /usr/local/lib/web/frontend/static/websockify/run
80+
81+
RUN ln -sf /usr/local/lib/web/frontend/static/vnc.html /usr/local/lib/web/frontend/static/index.html
82+
RUN ln -sf /usr/local/lib/web/frontend/static/novnc/vnc.html /usr/local/lib/web/frontend/static/novnc/index.html
83+
84+
EXPOSE 80
85+
86+
ENV HOME=/home/work \
87+
SHELL=/bin/bash
88+
HEALTHCHECK --interval=30s --timeout=5s CMD curl --fail http://127.0.0.1:6079/api/health
89+
90+
# Backend.AI specifics
91+
LABEL ai.backend.kernelspec="1" \
92+
ai.backend.envs.corecount="OPENBLAS_NUM_THREADS,OMP_NUM_THREADS,NPROC" \
93+
ai.backend.features="batch query uid-match user-input" \
94+
ai.backend.resource.min.cpu="1" \
95+
ai.backend.resource.min.mem="1g" \
96+
ai.backend.resource.preferred.shmem="512m" \
97+
ai.backend.base-distro="ubuntu18.04" \
98+
ai.backend.runtime-type="app" \
99+
ai.backend.service-ports="xfce:http:80,vnc:http:5900"
100+
101+
COPY ./service-defs /etc/backend.ai/service-defs
102+
COPY policy.yml /etc/backend.ai/jail/policy.yml
103+
COPY bootstrap_xfce.sh /opt/container/bootstrap.sh
104+
WORKDIR /home/work

ubuntu/bootstrap.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
3+
if [ -n "$VNC_PASSWORD" ]; then
4+
echo -n "$VNC_PASSWORD" > /.password1
5+
x11vnc -storepasswd $(cat /.password1) /.password2
6+
chmod 400 /.password*
7+
sed -i 's/^command=x11vnc.*/& -rfbauth \/.password2/' /etc/supervisor/conf.d/supervisord.conf
8+
export VNC_PASSWORD=
9+
fi
10+
11+
if [ -n "$X11VNC_ARGS" ]; then
12+
sed -i "s/^command=x11vnc.*/& ${X11VNC_ARGS}/" /etc/supervisor/conf.d/supervisord.conf
13+
fi
14+
15+
if [ -n "$OPENBOX_ARGS" ]; then
16+
sed -i "s#^command=/usr/bin/openbox.*#& ${OPENBOX_ARGS}#" /etc/supervisor/conf.d/supervisord.conf
17+
fi
18+
19+
if [ -n "$RESOLUTION" ]; then
20+
sed -i "s/1024x768/$RESOLUTION/" /usr/local/bin/xvfb.sh
21+
fi
22+
23+
#USER=${USER:-root}
24+
USER=work
25+
HOME=/home/work
26+
cp -r /root/{.gtkrc-2.0,.asoundrc} ${HOME}
27+
#[ -d "/dev/snd" ] && chgrp -R adm /dev/snd
28+
sed -i -e "s|%USER%|$USER|" -e "s|%HOME%|$HOME|" /etc/supervisor/conf.d/supervisord.conf
29+
30+
# home folder
31+
if [ ! -x "$HOME/.config/pcmanfm/LXDE/" ]; then
32+
mkdir -p $HOME/.config/pcmanfm/LXDE/
33+
ln -sf /usr/local/share/doro-lxde-wallpapers/desktop-items-0.conf $HOME/.config/pcmanfm/LXDE/
34+
chown -R $USER:$USER $HOME
35+
fi
36+
37+
# nginx workers
38+
sed -i 's|worker_processes .*|worker_processes 1;|' /etc/nginx/nginx.conf
39+
40+
echo ">> Starting background VNC server"
41+
printf "backendai\nbackendai\n\n" | /opt/kernel/su-exec $LOCAL_USER_ID:$LOCAL_GROUP_ID vncpasswd >/dev/null 2>&1
42+
43+
mkdir -p /home/work/.vnc
44+
cat >/home/work/.vnc/xstartup <<EOF
45+
#!/bin/sh
46+
xhost +
47+
# SESSION_MANAGER is inherited from the environment and some window
48+
# managers require that it be cleared.
49+
# http://osdir.com/ml/gnome.ximian.snapshots/2002-09/msg00034.html
50+
# For example, Xfce4 version 4.6.1 and Deb5-64 require the unsetenv.
51+
# Goolging indicates that others also require the unsetenv.
52+
unsetenv SESSION_MANAGER
53+
# Startup scripts, e.g. /etc/xdg/xfce4/xinitrc require
54+
# http://en.wikipedia.org/wiki/D-Bus to run correctly.
55+
unsetenv DBUS_SESSION_BUS_ADDRESS
56+
# Set VNCSESSION to tell /etc/xdg/xfce4/xinitrc to not run xscreensaver
57+
# http://vstone.eu/2009/04/disabling-xscreensaver-when-using-xfce-vnc/
58+
setenv VNCSESSION yes
59+
startxfce4 &
60+
# Make sure that copy / paste are correctly forwarded to the VNC viewer
61+
vncconfig -nowin &
62+
EOF
63+
chmod +x /home/work/.vnc/xstartup
64+
65+
cat >/home/work/.xscreensaver <<EOF
66+
mode: off
67+
EOF
68+
69+
chown -R $LOCAL_USER_ID:$LOCAL_GROUP_ID /home/work
70+
#/opt/kernel/su-exec $LOCAL_USER_ID:$LOCAL_GROUP_ID /usr/bin/vncserver -geometry 1600x1200
71+
72+
#echo ">> VNC server is started."
73+
74+
supervisord -c /etc/supervisor/supervisord.conf

ubuntu/bootstrap_gnome.sh

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
#!/bin/bash
2+
3+
if [ -n "$VNC_PASSWORD" ]; then
4+
echo -n "$VNC_PASSWORD" > /.password1
5+
x11vnc -storepasswd $(cat /.password1) /.password2
6+
chmod 400 /.password*
7+
sed -i 's/^command=x11vnc.*/& -rfbauth \/.password2/' /etc/supervisor/conf.d/supervisord.conf
8+
export VNC_PASSWORD=
9+
fi
10+
11+
if [ -n "$X11VNC_ARGS" ]; then
12+
sed -i "s/^command=x11vnc.*/& ${X11VNC_ARGS}/" /etc/supervisor/conf.d/supervisord.conf
13+
fi
14+
15+
if [ -n "$OPENBOX_ARGS" ]; then
16+
sed -i "s#^command=/usr/bin/openbox.*#& ${OPENBOX_ARGS}#" /etc/supervisor/conf.d/supervisord.conf
17+
fi
18+
19+
if [ -n "$RESOLUTION" ]; then
20+
sed -i "s/1024x768/$RESOLUTION/" /usr/local/bin/xvfb.sh
21+
fi
22+
23+
#USER=${USER:-root}
24+
USER=work
25+
HOME=/home/work
26+
cp -r /root/{.gtkrc-2.0,.asoundrc} ${HOME}
27+
#[ -d "/dev/snd" ] && chgrp -R adm /dev/snd
28+
sed -i -e "s|%USER%|$USER|" -e "s|%HOME%|$HOME|" /etc/supervisor/conf.d/supervisord.conf
29+
30+
# home folder
31+
if [ ! -x "$HOME/.config/pcmanfm/LXDE/" ]; then
32+
mkdir -p $HOME/.config/pcmanfm/LXDE/
33+
ln -sf /usr/local/share/doro-lxde-wallpapers/desktop-items-0.conf $HOME/.config/pcmanfm/LXDE/
34+
chown -R $USER:$USER $HOME
35+
fi
36+
37+
# nginx workers
38+
sed -i 's|worker_processes .*|worker_processes 1;|' /etc/nginx/nginx.conf
39+
40+
echo ">> Starting background VNC server"
41+
printf "backendai\nbackendai\n\n" | /opt/kernel/su-exec $LOCAL_USER_ID:$LOCAL_GROUP_ID vncpasswd >/dev/null 2>&1
42+
43+
mkdir -p /home/work/.vnc
44+
cat >/home/work/.vnc/xstartup <<EOF
45+
#!/bin/sh
46+
xhost +
47+
# SESSION_MANAGER is inherited from the environment and some window
48+
# managers require that it be cleared.
49+
# http://osdir.com/ml/gnome.ximian.snapshots/2002-09/msg00034.html
50+
# For example, Xfce4 version 4.6.1 and Deb5-64 require the unsetenv.
51+
# Goolging indicates that others also require the unsetenv.
52+
unsetenv SESSION_MANAGER
53+
# Startup scripts, e.g. /etc/xdg/xfce4/xinitrc require
54+
# http://en.wikipedia.org/wiki/D-Bus to run correctly.
55+
unsetenv DBUS_SESSION_BUS_ADDRESS
56+
# Set VNCSESSION to tell /etc/xdg/xfce4/xinitrc to not run xscreensaver
57+
# http://vstone.eu/2009/04/disabling-xscreensaver-when-using-xfce-vnc/
58+
setenv VNCSESSION yes
59+
setenv DISPLAY :1
60+
gnome-session &
61+
gnome-settings-daemon &
62+
metacity &
63+
nautilus &
64+
# Make sure that copy / paste are correctly forwarded to the VNC viewer
65+
vncconfig -nowin &
66+
EOF
67+
chmod +x /home/work/.vnc/xstartup
68+
69+
mkdir -p $HOME/.config/nautilus
70+
chown -R $USER:$USER $HOME/.config/nautilus
71+
mkdir -p $HOME/.gtk-bookmarks
72+
chown -R $USER:$USER $HOME/.gtk-bookmarks
73+
74+
cat >/home/work/.xscreensaver <<EOF
75+
mode: off
76+
EOF
77+
78+
chown -R $LOCAL_USER_ID:$LOCAL_GROUP_ID /home/work
79+
#/opt/kernel/su-exec $LOCAL_USER_ID:$LOCAL_GROUP_ID /usr/bin/vncserver -geometry 1600x1200
80+
81+
#echo ">> VNC server is started."
82+
83+
supervisord -c /etc/supervisor/supervisord.conf

0 commit comments

Comments
 (0)