From 8ab6af08250b7dda178794f390d223c1461da030 Mon Sep 17 00:00:00 2001 From: sneak Date: Fri, 17 May 2024 15:59:57 -0700 Subject: [PATCH] first commit --- Dockerfile | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ Makefile | 18 ++++++++++++++++ README.md | 11 ++++++++++ init.sh | 24 +++++++++++++++++++++ install.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ xstartup | 7 +++++++ 6 files changed, 176 insertions(+) create mode 100644 Dockerfile create mode 100644 Makefile create mode 100644 README.md create mode 100644 init.sh create mode 100644 install.sh create mode 100644 xstartup diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6085a9f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,55 @@ +# Use an official Ubuntu base image +FROM ubuntu:22.04 + +# Avoid warnings by switching to noninteractive for the build process +ENV DEBIAN_FRONTEND=noninteractive + +ENV USER=root + +# update system first +RUN apt update && apt upgrade -y + +# Install XFCE, VNC server, dbus-x11, and xfonts-base +RUN apt-get update && apt-get install -y --no-install-recommends \ + ca-certificates \ + dbus-x11 \ + tightvncserver \ + vim \ + xfce4 \ + xfce4-goodies \ + xfonts-base \ + xinit \ + wget \ + curl \ + xterm + +WORKDIR /tmp +COPY ./install.sh ./install.sh +RUN bash ./install.sh + +# Setup VNC server +RUN mkdir /root/.vnc \ + && echo "password" | vncpasswd -f > /root/.vnc/passwd \ + && chmod 600 /root/.vnc/passwd + +COPY ./xstartup /root/.vnc/xstartup + +# Create an .Xauthority file +RUN touch /root/.Xauthority + +RUN chmod ugoa+rx /root/.vnc/xstartup + +# Set display resolution (change as needed) +ENV RESOLUTION=1920x1080 + +# Expose VNC port +EXPOSE 5901 + +# Set the working directory in the container +WORKDIR /app + +# Copy a script to start the VNC server +COPY init.sh init.sh +RUN chmod +x init.sh + +CMD ["/app/init.sh"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..75ae685 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +export DOCKER_HOST := ssh://root@las1 + +build: + docker build \ + -t sneak/vnc-desktop \ + --progress plain \ + . + +run: + docker rm -f vnc-desktop + docker run \ + -d -p 5901:5901 \ + --name vnc-desktop \ + --security-opt seccomp=unconfined \ + sneak/vnc-desktop + +logs: + docker logs -f vnc-desktop diff --git a/README.md b/README.md new file mode 100644 index 0000000..9a598be --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# vnc-desktop + +containerized xfce4 ubuntu jaunty vnc desktop + +# TODO + +make it work as nonroot + +get resizing support working +fix blurry fonts + diff --git a/init.sh b/init.sh new file mode 100644 index 0000000..5e834fd --- /dev/null +++ b/init.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +echo 'Updating /etc/hosts file...' +HOSTNAME=$(hostname) +echo "127.0.1.1\t$HOSTNAME" >> /etc/hosts + +echo "Starting VNC server" +vncserver -kill :1 || true +vncserver -geometry 1600x1200 +#vncserver -geometry 1600x1200 -randr 1920x1080,1600x1200,1440x900,1024x768 & + +echo "VNC server started at $RESOLUTION! ^-^" + +export DISPLAY=":1" + +xset -dpms & +xset s noblank & +xset s off & +/usr/bin/startxfce4 --replace > $HOME/wm.log & + +xterm & +sleep 1 + +tail -f $HOME/wm.log $HOME/.vnc/*.log diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..0679083 --- /dev/null +++ b/install.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +set -x + + +PKGS=" + alacritty + binutils + build-essential + byobu + ca-certificates + ctags + cups-common + curl + desktop-base + elementary-xfce-icon-theme + htop + jq + less + libnotify-bin + lsb-release + make + netbase + pastebinit + publicsuffix + run-one + screen + sudo + ttf-ubuntu-font-family + update-notifier-common + vim-doc + vim-scripts + wget + wordlist + xarchiver + xdg-user-dirs + xfdesktop4 + xfdesktop4-data + zsh + zsh-doc + zstd +" + +export DEBIAN_FRONTEND=noninteractive + +apt install -y PKGS + +install -d -m 0755 /etc/apt/keyrings +wget -q https://packages.mozilla.org/apt/repo-signing-key.gpg -O- | tee /etc/apt/keyrings/packages.mozilla.org.asc > /dev/null +echo "deb [signed-by=/etc/apt/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | tee -a /etc/apt/sources.list.d/mozilla.list > /dev/null +echo ' +Package: * +Pin: origin packages.mozilla.org +Pin-Priority: 1000 +' | tee /etc/apt/preferences.d/mozilla +apt update +apt install -y firefox + + +apt-get clean +rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* diff --git a/xstartup b/xstartup new file mode 100644 index 0000000..4c5b855 --- /dev/null +++ b/xstartup @@ -0,0 +1,7 @@ +#!/bin/sh +unset SESSION_MANAGER +unset DBUS_SESSION_BUS_ADDRESS +xsetroot -solid grey +autocutsel -fork +#geometry 640x480 +startxfce4 &