-
Notifications
You must be signed in to change notification settings - Fork 9
/
Dockerfile.ubuntu20.04
116 lines (105 loc) · 3.93 KB
/
Dockerfile.ubuntu20.04
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
FROM ubuntu:20.04
# For slim:
# --build-arg ADDITIONAL_APT_GET_OPTS=--no-install-recommends
ARG ADDITIONAL_APT_GET_OPTS=""
RUN echo 'path-include=/usr/share/locale/ja/LC_MESSAGES/*.mo' > /etc/dpkg/dpkg.cfg.d/includes \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y $ADDITIONAL_APT_GET_OPTS \
dbus-x11 \
fonts-noto-cjk \
gosu \
ibus \
ibus-gtk \
ibus-gtk3 \
ibus-mozc \
im-config \
language-pack-ja \
language-pack-ja-base \
lxde \
net-tools \
novnc \
sudo \
supervisor \
x11vnc \
xvfb \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Set locale
RUN cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \
&& echo 'Asia/Tokyo' > /etc/timezone \
&& locale-gen ja_JP.UTF-8 \
&& echo 'LC_ALL=ja_JP.UTF-8' > /etc/default/locale \
&& echo 'LANG=ja_JP.UTF-8' >> /etc/default/locale
ENV LANG=ja_JP.UTF-8 \
LANGUAGE=ja_JP:ja \
LC_ALL=ja_JP.UTF-8
# Set default vars
ENV DEFAULT_USER=developer \
DEFAULT_PASSWD=vncpasswd
# Set sudoers for any user
RUN echo "ALL ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/ALL
# Change permission so that non-root user can add users and groups
RUN chmod u+s /usr/sbin/useradd \
&& chmod u+s /usr/sbin/groupadd
# Expose VNC and noVNC ports
EXPOSE 5900
EXPOSE 80
RUN install -o root -g root -m 0755 -d /var/run/dbus \
&& sed -i 's|\[Session\]|&\npolkit/command=|' /etc/xdg/lxsession/LXDE/desktop.conf \
&& ln -s /usr/share/lxde/wallpapers/lxde_green.jpg /etc/alternatives/desktop-background
# Set supervisord conf
RUN { \
echo '[supervisord]'; \
echo 'user=root'; \
echo 'nodaemon=true'; \
echo 'logfile=/var/log/supervisor/supervisord.log'; \
echo 'childlogdir=/var/log/supervisor'; \
echo '[program:dbus]'; \
echo 'priority=10'; \
echo 'command=/usr/bin/dbus-daemon --system --nofork --nopidfile'; \
echo '[program:lightdm]'; \
echo 'priority=20'; \
echo 'command=/usr/local/bin/start-lightdm.sh'; \
echo '[program:x11vnc]'; \
echo 'priority=30'; \
echo 'startretries=5'; \
echo 'command=/usr/bin/x11vnc -display :0 -auth /var/run/lightdm/root/:0 -rfbauth /etc/x11vnc.passwd -xkb -forever -shared -repeat -capslock'; \
echo '[program:novnc]'; \
echo 'priority=40'; \
echo 'user=${USER}'; \
echo 'command=/usr/share/novnc/utils/launch.sh --vnc localhost:5900 --listen 80'; \
} > /etc/supervisor/vnc.conf.template
# Set scripts and configuration for lightdm and Xvfb
RUN { \
# This script waits for D-Bus to be ready, then starts lightdm.
# If lightdm starts before D-Bus is active, the startup of lightdm may fail.
# Therefore, it is necessary to wait until D-Bus is ready before starting lightdm.
# This script was created to solve this problem.
echo '#!/bin/sh'; \
echo 'while true'; \
echo 'do'; \
echo ' busctl > /dev/null 2>&1 && break'; \
echo ' sleep 0.1'; \
echo 'done'; \
echo 'exec /usr/sbin/lightdm'; \
} > /usr/local/bin/start-lightdm.sh \
&& chmod +x /usr/local/bin/start-lightdm.sh \
&& { \
# This script starts Xvfb with the given resolution
echo '#!/bin/sh'; \
echo 'RESOLUTION="$1"'; \
echo 'exec /usr/bin/Xvfb :0 -screen 0 "$RESOLUTION" -nolisten tcp'; \
} > /usr/local/bin/start-Xvfb.sh \
&& chmod +x /usr/local/bin/start-Xvfb.sh \
&& { \
# This is a template for lightdm configuration
echo '[Seat:*]'; \
echo 'xserver-command=/usr/local/bin/start-Xvfb.sh "${RESOLUTION}"'; \
echo 'autologin-user=${USER}'; \
echo 'autologin-user-timeout=0'; \
echo 'autologin-session=LXDE'; \
} > /etc/lightdm/lightdm.conf.template
# Copy entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]