|
| 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"] |
0 commit comments