-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvnc.dockerfile
More file actions
109 lines (89 loc) · 3.53 KB
/
Copy pathvnc.dockerfile
File metadata and controls
109 lines (89 loc) · 3.53 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
ARG BASE_IMAGE=debian:trixie-slim
FROM ${BASE_IMAGE} AS base
ARG BASE_IMAGE
ARG username=lcas
ENV BASE_IMAGE=${BASE_IMAGE}
ENV DEBIAN_FRONTEND=noninteractive \
DISPLAY=:1
# Install timezone
RUN ln -fs /usr/share/zoneinfo/UTC /etc/localtime \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y --no-install-recommends tzdata \
&& dpkg-reconfigure --frontend noninteractive tzdata \
&& rm -rf /var/lib/apt/lists/*
# Install packages
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gnupg2 \
lsb-release \
wget \
libglvnd0 \
libgl1 \
libglx0 \
libegl1 \
libxext6 \
libx11-6 \
x11-utils \
screen \
sudo \
unzip \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user
RUN useradd -m -s /bin/bash -G video,sudo ${username}
# Allow passwordless sudo for users in sudo group
RUN echo '%sudo ALL=(ALL:ALL) NOPASSWD:ALL' > /etc/sudoers.d/99-sudo-nopasswd \
&& chmod 0440 /etc/sudoers.d/99-sudo-nopasswd
# Fix /tmp/.X11-unix permissions
RUN mkdir -p /tmp/.X11-unix \
&& chmod 1777 /tmp/.X11-unix
# Install Python 3 for noVNC/websockify
RUN apt-get update && apt-get install -y python3 && rm -rf /var/lib/apt/lists/*
# Install TurboVNC
RUN wget -q -O- https://packagecloud.io/dcommander/turbovnc/gpgkey | gpg --dearmor >/etc/apt/trusted.gpg.d/TurboVNC.gpg \
&& echo "deb [signed-by=/etc/apt/trusted.gpg.d/TurboVNC.gpg] https://packagecloud.io/dcommander/turbovnc/any/ any main" >>/etc/apt/sources.list.d/TurboVNC.list \
&& apt-get update && apt-get install -y turbovnc && rm -rf /var/lib/apt/lists/*
# Install noVNC
ENV NOVNC_VERSION=1.6.0
ENV WEBSOCKETIFY_VERSION=0.13.0
RUN mkdir -p /usr/local/novnc \
&& curl -sSL https://github.com/novnc/noVNC/archive/v${NOVNC_VERSION}.zip -o /tmp/novnc-install.zip \
&& unzip /tmp/novnc-install.zip -d /usr/local/novnc \
&& cp /usr/local/novnc/noVNC-${NOVNC_VERSION}/vnc.html /usr/local/novnc/noVNC-${NOVNC_VERSION}/index.html \
&& curl -sSL https://github.com/novnc/websockify/archive/v${WEBSOCKETIFY_VERSION}.zip -o /tmp/websockify-install.zip \
&& unzip /tmp/websockify-install.zip -d /usr/local/novnc \
&& ln -s /usr/local/novnc/websockify-${WEBSOCKETIFY_VERSION} /usr/local/novnc/noVNC-${NOVNC_VERSION}/utils/websockify \
&& rm -f /tmp/websockify-install.zip /tmp/novnc-install.zip \
&& sed -i -E 's/^python /python3 /' /usr/local/novnc/websockify-${WEBSOCKETIFY_VERSION}/run
FROM base AS xfce
# Install XFCE4
RUN apt-get update \
&& apt-get -y install \
xfce4-session \
xfce4-panel \
xfdesktop4 \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get purge -y xfce4-screensaver
COPY vnc-entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
COPY vnc-healthcheck.sh /vnc-healthcheck.sh
RUN chmod +x /vnc-healthcheck.sh
# start_period allows the VNC stack time to fully initialize before health checks start counting failures
HEALTHCHECK --interval=10s --timeout=5s --start-period=60s --retries=5 \
CMD ["/vnc-healthcheck.sh"]
# Copy in wallpaper
COPY ./wallpapers/*.jpg /usr/share/backgrounds/xfce/
# Allow other containers to share windows into this display
RUN echo 'xhost +local: 2>/dev/null' >> /etc/bash.bashrc && \
echo "if [ -f /etc/bash.bashrc ]; then source /etc/bash.bashrc; fi" >> /root/.bashrc
EXPOSE 5801
USER ${username}
ENV HOME=/home/${username}
WORKDIR ${HOME}
RUN mkdir -p ${HOME}/.local/bin
ENV DISPLAY=:1
ENV TVNC_VGL=1
ENV SHELL=/bin/bash
CMD ["sleep", "infinity"]