Skip to content

Commit 6421bc5

Browse files
committed
feat: add gnome ubuntu image builder (testing)
1 parent 243813f commit 6421bc5

File tree

6 files changed

+212
-9
lines changed

6 files changed

+212
-9
lines changed

ubuntu/Dockerfile.18.04.xfce.amd64

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,36 +74,31 @@ LABEL maintainer="[email protected]"
7474

7575
COPY --from=builder /src/web/dist/ /usr/local/lib/web/frontend/
7676
COPY rootfs /
77+
RUN cp /etc/supervisor/conf.d/supervisord.xfce /etc/supervisor/conf.d/supervisord.conf
7778
RUN ln -sf /usr/local/lib/web/frontend/static/websockify /usr/local/lib/web/frontend/static/novnc/utils/websockify && \
7879
chmod +x /usr/local/lib/web/frontend/static/websockify/run
7980

8081
RUN ln -sf /usr/local/lib/web/frontend/static/vnc.html /usr/local/lib/web/frontend/static/index.html
8182
RUN ln -sf /usr/local/lib/web/frontend/static/novnc/vnc.html /usr/local/lib/web/frontend/static/novnc/index.html
8283

8384
EXPOSE 80
84-
WORKDIR /home/work
8585

8686
ENV HOME=/home/work \
8787
SHELL=/bin/bash
8888
HEALTHCHECK --interval=30s --timeout=5s CMD curl --fail http://127.0.0.1:6079/api/health
8989

90-
91-
#RUN /setup.sh
92-
93-
#ENTRYPOINT ["/startup.sh"]
94-
9590
# Backend.AI specifics
9691
LABEL ai.backend.kernelspec="1" \
9792
ai.backend.envs.corecount="OPENBLAS_NUM_THREADS,OMP_NUM_THREADS,NPROC" \
9893
ai.backend.features="batch query uid-match user-input" \
9994
ai.backend.resource.min.cpu="1" \
10095
ai.backend.resource.min.mem="1g" \
96+
ai.backend.resource.preferred.shmem="512m" \
10197
ai.backend.base-distro="ubuntu18.04" \
102-
ai.backend.runtime-type="python" \
103-
ai.backend.runtime-path="/usr/bin/python3" \
98+
ai.backend.runtime-type="app" \
10499
ai.backend.service-ports="xfce:http:80,vnc:http:5900"
105100

106101
COPY ./service-defs /etc/backend.ai/service-defs
107102
COPY policy.yml /etc/backend.ai/jail/policy.yml
108-
COPY bootstrap.sh /opt/container/bootstrap.sh
103+
COPY bootstrap_xfce.sh /opt/container/bootstrap.sh
109104
WORKDIR /home/work

ubuntu/bootstrap_gnome.sh

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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+
gnome-session &
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+
mkdir -p $HOME/.config/nautilus
66+
chown -R $USER:$USER $HOME/.config/nautilus
67+
68+
cat >/home/work/.xscreensaver <<EOF
69+
mode: off
70+
EOF
71+
72+
chown -R $LOCAL_USER_ID:$LOCAL_GROUP_ID /home/work
73+
#/opt/kernel/su-exec $LOCAL_USER_ID:$LOCAL_GROUP_ID /usr/bin/vncserver -geometry 1600x1200
74+
75+
#echo ">> VNC server is started."
76+
77+
supervisord -c /etc/supervisor/supervisord.conf

ubuntu/bootstrap_xfce.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
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[supervisord]
2+
redirect_stderr=true
3+
stopsignal=QUIT
4+
autorestart=true
5+
directory=/root
6+
7+
[program:nginx]
8+
priority=10
9+
command=nginx -c /etc/nginx/nginx.conf -g 'daemon off;'
10+
11+
[program:web]
12+
priority=10
13+
directory=/usr/local/lib/web/backend
14+
command=/usr/local/lib/web/backend/run.py
15+
#stdout_logfile=/dev/fd/1
16+
#stdout_logfile_maxbytes=0
17+
#stderr_logfile=/dev/fd/1
18+
#stderr_logfile_maxbytes=0
19+
20+
[group:x]
21+
programs=xvfb,lxpanel,x11vnc,novnc
22+
23+
[program:lxpanel]
24+
priority=15
25+
directory=%HOME%
26+
command=/usr/bin/gnome-session
27+
user=%USER%
28+
environment=DISPLAY=":1",HOME="%HOME%",USER="%USER%"
29+
30+
[program:xvfb]
31+
priority=10
32+
command=/usr/local/bin/xvfb.sh
33+
stopsignal=KILL
34+
35+
[program:x11vnc]
36+
priority=20
37+
command=x11vnc -display :1 -xkb -forever -shared -repeat -ncache 10
38+
39+
[program:novnc]
40+
priority=25
41+
directory=/usr/local/lib/web/frontend/static/novnc
42+
command=bash /usr/local/lib/web/frontend/static/novnc/utils/launch.sh --listen 6081
43+
stopasgroup=true

ubuntu/service-defs/gnome.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"prestart": [],
3+
"command": [
4+
"true"
5+
],
6+
"allowed_arguments": [
7+
],
8+
"allowed_envs": [
9+
"PASSWORD"
10+
],
11+
"default_arguments": {
12+
"--auth": "none"
13+
}
14+
}

0 commit comments

Comments
 (0)