Skip to content

Commit 732a665

Browse files
init: added basic ubuntu desktop with vnc, de, shell, and fs
0 parents  commit 732a665

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

Dockerfile

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Use Ubuntu 22.04 as base
2+
FROM ubuntu:22.04 AS base
3+
4+
# Avoid interactive prompts during installation
5+
ENV DEBIAN_FRONTEND=noninteractive
6+
7+
# Install core utilities
8+
RUN apt-get update && apt-get install -y --no-install-recommends \
9+
sudo \
10+
wget \
11+
net-tools \
12+
dbus-x11 \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
# Stage for desktop environment
16+
FROM base AS desktop
17+
# Install XFCE related packages
18+
RUN apt-get update && apt-get install -y --no-install-recommends \
19+
xfce4 \
20+
xfce4-goodies \
21+
xfonts-base \
22+
xauth \
23+
&& rm -rf /var/lib/apt/lists/*
24+
25+
# Stage for VNC setup
26+
FROM desktop AS vnc
27+
# Install VNC related packages
28+
RUN apt-get update && apt-get install -y --no-install-recommends \
29+
tightvncserver \
30+
novnc \
31+
websockify \
32+
&& rm -rf /var/lib/apt/lists/*
33+
34+
# Final stage
35+
FROM vnc AS final
36+
37+
# Create a non-root user 'sandbox'
38+
RUN useradd -m -s /bin/bash sandbox && \
39+
echo "sandbox:password" | chpasswd && \
40+
adduser sandbox sudo
41+
42+
# Set up VNC directory and password for the sandbox user
43+
RUN mkdir -p /home/sandbox/.vnc && \
44+
echo "password" | vncpasswd -f > /home/sandbox/.vnc/passwd
45+
46+
# Create an empty .Xauthority file
47+
RUN touch /home/sandbox/.Xauthority
48+
49+
# Set ownership and permissions for VNC and Xauthority files
50+
RUN chown -R sandbox:sandbox /home/sandbox/.vnc /home/sandbox/.Xauthority && \
51+
chmod 0600 /home/sandbox/.vnc/passwd && \
52+
chmod 0600 /home/sandbox/.Xauthority
53+
54+
# Copy startup and self-destruct scripts
55+
COPY entrypoint.sh /entrypoint.sh
56+
COPY self_destruct.sh /self_destruct.sh
57+
RUN chmod +x /entrypoint.sh /self_destruct.sh
58+
59+
# Expose noVNC port
60+
EXPOSE 6080
61+
62+
# Set user and working directory
63+
USER sandbox
64+
WORKDIR /home/sandbox
65+
66+
# Set the entrypoint script
67+
ENTRYPOINT ["/entrypoint.sh"]

entrypoint.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# Start the self-destruct timer in the background
4+
/self_destruct.sh &
5+
6+
# Explicitly set the USER environment variable
7+
export USER=sandbox
8+
9+
# Start VNC server on display :1 with specific geometry and depth
10+
# Removed invalid '-localhost no' option
11+
vncserver :1 -geometry 1280x800 -depth 24 -rfbport 5901
12+
13+
# Start noVNC using websockify, listening on port 6080 and forwarding to VNC server on 5901
14+
websockify --web /usr/share/novnc/ 6080 localhost:5901 &
15+
16+
# Keep the container running - tailing the VNC log is a simple way
17+
# Wait a moment for the log file to be created
18+
sleep infinity

self_destruct.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
echo "Container will self-destruct in 10 minutes."
4+
sleep 600 # 10 minutes * 60 seconds/minute
5+
6+
echo "Time's up! Stopping container."
7+
# A simple way to stop the container is to kill the entrypoint process (PID 1)
8+
kill 1

0 commit comments

Comments
 (0)