-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebian.dockerfile
More file actions
88 lines (79 loc) · 3.64 KB
/
Copy pathdebian.dockerfile
File metadata and controls
88 lines (79 loc) · 3.64 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
# Use a minimal base image
FROM debian:stable-slim
# Build arguments to set environment variables at build time
ARG DEF_XRDP_PORT=3389
ARG DEF_STARTING_WEBSITE_URL=https://www.google.com
ARG DEF_LANG=en_US.UTF-8
ARG DEF_LC_ALL=C.UTF-8
ARG DEF_CUSTOMIZE=false
ARG DEF_CUSTOM_ENTRYPOINTS_DIR=/app/custom_entrypoints_scripts
ARG DEF_AUTO_START_BROWSER=true
ARG DEF_DEBIAN_FRONTEND=noninteractive
ARG DEF_XRDP_USER=rdpuser
ARG DEF_XRDP_PASSWORD=money4band
ENV XRDP_USER=${DEF_XRDP_USER} XRDP_PASSWORD=${DEF_XRDP_PASSWORD}
# Set environment variables with default values
ENV \
STARTING_WEBSITE_URL=${DEF_STARTING_WEBSITE_URL} \
LANG=${DEF_LANG} \
LC_ALL=${DEF_LC_ALL} \
CUSTOMIZE=${DEF_CUSTOMIZE} \
CUSTOM_ENTRYPOINTS_DIR=${DEF_CUSTOM_ENTRYPOINTS_DIR} \
AUTO_START_BROWSER=${DEF_AUTO_START_BROWSER} \
DEBIAN_FRONTEND=${DEF_DEBIAN_FRONTEND} \
XRDP_PORT=${DEF_XRDP_PORT}
# Install necessary packages and setup noVNC
RUN set -e; \
apt update && \
apt full-upgrade -qqy && \
apt install -qqy \
tini \
supervisor \
bash \
xrdp \
fluxbox \
nano \
chromium \
dbus-x11 \
xvfb \
x11-xserver-utils \
firejail && \
useradd -m -s /bin/bash "${XRDP_USER}" && \
echo "${XRDP_USER}:${XRDP_PASSWORD}" | chpasswd && \
# create fluxbox directory and secure menu
mkdir -p /home/${XRDP_USER}/.fluxbox && \
# create an .xsession so xrdp will launch Chromium on session start
echo '#!/bin/sh' > /home/${XRDP_USER}/.xsession && \
echo 'exec /usr/local/bin/fluxbox-startup &' >> /home/${XRDP_USER}/.xsession && \
echo 'sleep 3' >> /home/${XRDP_USER}/.xsession && \
echo 'firejail --profile=/etc/firejail/chromium-secure.profile /usr/bin/chromium --no-sandbox --disable-dev-shm-usage --start-maximized --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-renderer-backgrounding --disable-features=TranslateUI --disable-ipc-flooding-protection "${STARTING_WEBSITE_URL}" &' >> /home/${XRDP_USER}/.xsession && \
echo '# Keep the session alive' >> /home/${XRDP_USER}/.xsession && \
echo 'while true; do' >> /home/${XRDP_USER}/.xsession && \
echo ' sleep 86400' >> /home/${XRDP_USER}/.xsession && \
echo 'done' >> /home/${XRDP_USER}/.xsession && \
apt autoremove --purge -y && \
apt clean && \
rm -rf /var/lib/apt/lists/*
# Fix ownership and permissions after copying all files
RUN chown -R ${DEF_XRDP_USER}:${DEF_XRDP_USER} /home/${DEF_XRDP_USER}/.fluxbox /home/${DEF_XRDP_USER}/.xsession && \
chmod +x /home/${DEF_XRDP_USER}/.xsession
# Create necessary directories for supervisor and custom entrypoints
RUN mkdir -p /etc/supervisor.d /app/conf.d ${DEF_CUSTOM_ENTRYPOINTS_DIR}
RUN mkdir -p /var/log/supervisor
# Copy configuration files
COPY supervisord.conf /etc/supervisor.d/supervisord.conf
# only bring in xrdp programs, drop VNC and xterm configs
COPY conf.d/xrdp.conf conf.d/xvfb.conf /app/conf.d/
COPY base_entrypoint.sh customizable_entrypoint.sh /usr/local/bin/
COPY browser_conf/chromium.conf /app/conf.d/
COPY fluxbox-menu /home/${DEF_XRDP_USER}/.fluxbox/menu
COPY fluxbox-init /home/${DEF_XRDP_USER}/.fluxbox/init
COPY fluxbox-startup /usr/local/bin/fluxbox-startup
COPY chromium-secure.profile /etc/firejail/chromium-secure.profile
# Make the entrypoint scripts executable
RUN chmod +x /usr/local/bin/base_entrypoint.sh /usr/local/bin/customizable_entrypoint.sh /usr/local/bin/fluxbox-startup
# Expose the XRDP port
EXPOSE ${XRDP_PORT}
# Set tini as the entrypoint and the custom script as the command
ENTRYPOINT ["/usr/bin/tini", "--"]
CMD ["/usr/local/bin/customizable_entrypoint.sh"]