feat: Add webbased VNC viewer (#306)

This commit is contained in:
Kroese 2024-01-07 22:37:58 +01:00 committed by GitHub
parent f54ef967c7
commit 003181333c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 12 deletions

View file

@ -2,18 +2,21 @@ FROM debian:trixie-slim
ARG DEBCONF_NOWARNINGS="yes" ARG DEBCONF_NOWARNINGS="yes"
ARG DEBIAN_FRONTEND noninteractive ARG DEBIAN_FRONTEND noninteractive
ARG DEBCONF_NONINTERACTIVE_SEEN true
RUN apt-get update \ RUN apt-get update \
&& apt-get --no-install-recommends -y install \ && apt-get --no-install-recommends -y install \
tini \ tini \
wget \ wget \
ovmf \ ovmf \
novnc \
procps \ procps \
iptables \ iptables \
iproute2 \ iproute2 \
dnsmasq \ dnsmasq \
net-tools \ net-tools \
qemu-utils \ qemu-utils \
websockify \
ca-certificates \ ca-certificates \
netcat-openbsd \ netcat-openbsd \
qemu-system-x86 \ qemu-system-x86 \
@ -24,7 +27,7 @@ COPY ./src /run/
RUN chmod +x /run/*.sh RUN chmod +x /run/*.sh
VOLUME /storage VOLUME /storage
EXPOSE 22 5900 EXPOSE 22 5900 8006
ENV CPU_CORES "1" ENV CPU_CORES "1"
ENV RAM_SIZE "1G" ENV RAM_SIZE "1G"

View file

@ -16,6 +16,11 @@ cd /run
. config.sh # Configure arguments . config.sh # Configure arguments
trap - ERR trap - ERR
if [[ "${DISPLAY,,}" == "vnc" ]]; then
websockify -D --web /usr/share/novnc/ 8006 localhost:5900
fi
info "Booting image using $VERS..." info "Booting image using $VERS..."
[[ "$DEBUG" == [Yy1]* ]] && set -x [[ "$DEBUG" == [Yy1]* ]] && set -x

View file

@ -1,16 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -Eeuo pipefail set -Eeuo pipefail
BASE="boot.img"
[ -f "$STORAGE/$BASE" ] && return 0
if [ -z "$BOOT" ]; then
error "No boot disk specified, set BOOT= to the URL of an ISO file." && exit 64
fi
BASE=$(basename "$BOOT")
[ -f "$STORAGE/$BASE" ] && return 0
# Check if running with interactive TTY or redirected to docker log # Check if running with interactive TTY or redirected to docker log
if [ -t 1 ]; then if [ -t 1 ]; then
PROGRESS="--progress=bar:noscroll" PROGRESS="--progress=bar:noscroll"
@ -34,6 +24,16 @@ if [[ "${BOOT_MODE,,}" == "windows" ]]; then
fi fi
fi fi
BASE="boot.img"
[ -f "$STORAGE/$BASE" ] && return 0
if [ -z "$BOOT" ]; then
error "No boot disk specified, set BOOT= to the URL of an ISO file." && exit 64
fi
BASE=$(basename "$BOOT")
[ -f "$STORAGE/$BASE" ] && return 0
TMP="$STORAGE/${BASE%.*}.tmp" TMP="$STORAGE/${BASE%.*}.tmp"
rm -f "$TMP" rm -f "$TMP"

View file

@ -95,9 +95,10 @@ getPorts() {
local list=$1 local list=$1
local vnc="5900" local vnc="5900"
local novnc="8006"
if [[ "${DISPLAY,,}" == "vnc" ]] && [[ "$list" != *"$vnc"* ]]; then if [[ "${DISPLAY,,}" == "vnc" ]] && [[ "$list" != *"$vnc"* ]]; then
[ -z "$list" ] && list="$vnc" || list="$list,$vnc" [ -z "$list" ] && list="$vnc,$novnc" || list="$list,$vnc,$novnc"
fi fi
[ -z "$list" ] && return 0 [ -z "$list" ] && return 0