-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathDockerfile
More file actions
109 lines (94 loc) · 4.08 KB
/
Copy pathDockerfile
File metadata and controls
109 lines (94 loc) · 4.08 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
FROM i386/debian:bookworm-slim
WORKDIR /root/build
ENV DEBIAN_FRONTEND=noninteractive
# Base Setup
RUN apt-get update && \
apt-get install -y --no-install-recommends \
linux-image-686 \
systemd-sysv \
locales \
libterm-readline-perl-perl \
&& rm -rf /var/lib/apt/lists/*
RUN echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen && \
locale-gen && \
echo 'LANG="en_US.UTF-8"' > /etc/default/locale && \
chsh -s /bin/bash root
RUN apt-get update && \
apt-get install -y --no-install-recommends \
xserver-xorg-core xserver-xorg-video-fbdev xinit \
xfce4 xfce4-terminal \
xserver-xorg-input-mouse xserver-xorg-input-kbd xserver-xorg-input-evdev \
libxext6 libxrender1 libxtst6 libxi6 libx11-xcb1 libxrender-dev \
libfontconfig1 fonts-dejavu-core adwaita-icon-theme fonts-wqy-microhei fonts-symbola \
wget tar unzip ca-certificates xterm \
xdg-utils shared-mime-info dbus-x11 desktop-base \
thunar-archive-plugin xfce4-taskmanager ristretto \
gvfs fonts-liberation xfce4-notifyd gvfs-backends \
isc-dhcp-client iproute2 iputils-ping sudo \
cmake git tmux mc htop vim nano p7zip-full geany mousepad atril engrampa curl build-essential \
firefox-esr libreoffice thunar pavucontrol xfce4-screenshooter thunderbird gimp \
&& rm -rf /var/lib/apt/lists/*
# Configure Root and Standard User ('username')
RUN passwd -d root && \
sed -i 's/nullok_secure/nullok/' /etc/pam.d/common-auth && \
useradd -m -s /bin/bash username && \
passwd -d username && \
usermod -aG sudo,video,tty,input,dialout username && \
echo "username ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
# Configure Serial Console Auto-login
RUN mkdir -p /etc/systemd/system/getty@tty1.service.d /etc/systemd/system/serial-getty@ttyS0.service.d && \
printf '%s\n' \
'[Service]' \
'TTYVTDisallocate=no' \
> /etc/systemd/system/getty@tty1.service.d/getty-noclear.conf && \
printf '%s\n' \
'[Service]' \
'ExecStart=' \
'ExecStart=-/sbin/agetty --autologin username --noissue --noclear %I 38400 $TERM' \
> /etc/systemd/system/getty@tty1.service.d/getty-override.conf && \
printf '%s\n' \
'[Service]' \
'ExecStart=' \
'ExecStart=-/sbin/agetty --autologin username --noissue --noclear -s %I 115200,38400,9600 vt102' \
> /etc/systemd/system/serial-getty@ttyS0.service.d/getty-autologin-serial.conf
# Disable Unnecessary Services
RUN systemctl disable systemd-timesyncd.service && \
systemctl disable apt-daily.timer && \
systemctl disable apt-daily-upgrade.timer
# 9p Filesystem Boot Configuration
# the boot script switches on the kernel command line: root=host9p mounts the
# 9p filesystem, anything else falls back to the standard disk boot
RUN printf '%s\n' 9p 9pnet 9pnet_virtio virtio virtio_ring virtio_pci | tee -a /etc/initramfs-tools/modules
RUN printf '%s\n' \
'#!/bin/sh' \
'case $1 in prereqs) exit 0;; esac' \
'. /scripts/functions' \
'if [ "${ROOT}" = "host9p" ]; then' \
' mkdir -p ${rootmnt}' \
' mount -n -t 9p -o trans=virtio,version=9p2000.L,cache=loose,rw host9p ${rootmnt}' \
'else' \
' . /scripts/local' \
'fi' \
> /etc/initramfs-tools/scripts/boot-9p && \
chmod +x /etc/initramfs-tools/scripts/boot-9p
RUN echo 'BOOT=boot-9p' | tee -a /etc/initramfs-tools/initramfs.conf
RUN update-initramfs -u
# Configure X11, Networking, and Auto-start for 'username'
RUN echo '(sleep 5 && sudo bash -c "printf \"\\n\\nGUI_READY\\n\" > /dev/ttyS0") & \n\
exec startxfce4' > /home/username/.xinitrc
RUN { \
echo 'if [ -z "$DISPLAY" ]; then'; \
echo ' sudo bash -c "echo 127.0.0.1 localhost > /etc/hosts"'; \
echo ' sudo bash -c "echo localhost > /etc/hostname"'; \
echo ' sudo hostname localhost'; \
echo ' startx -- -ac'; \
echo 'fi'; \
} >> /home/username/.bashrc
RUN chown username:username /home/username/.xinitrc /home/username/.bashrc
# Force Xorg to use the FBDEV driver
RUN mkdir -p /etc/X11/xorg.conf.d && \
echo 'Section "Device"\n\
Identifier "Card0"\n\
Driver "fbdev"\n\
EndSection' > /etc/X11/xorg.conf.d/10-fbdev.conf
WORKDIR /home/username