Skip to content

Commit

Permalink
improved noVNC (issue #23, heartbeat)
Browse files Browse the repository at this point in the history
  • Loading branch information
accetto committed Mar 20, 2022
1 parent 7c4ee9b commit 3a55f2c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
22 changes: 13 additions & 9 deletions docker/Dockerfile.xfce
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,23 @@ EXPOSE ${VNC_PORT}

FROM stage_vnc as stage_novnc
ARG ARG_APT_NO_RECOMMENDS
ARG ARG_NO_VNC_PORT
ARG ARG_NOVNC_PORT

ENV \
FEATURES_BUILD_SLIM_NOVNC=${ARG_APT_NO_RECOMMENDS:+1} \
FEATURES_NOVNC=1 \
NO_VNC_HOME=/usr/libexec/noVNCdim \
NO_VNC_PORT=${ARG_NO_VNC_PORT:-6901}
NOVNC_HOME=/usr/libexec/noVNCdim \
NOVNC_PORT=${ARG_NOVNC_PORT:-6901}

RUN \
mkdir -p "${NO_VNC_HOME}"/utils/websockify \
&& wget -qO- https://github.com/novnc/noVNC/archive/v1.3.0.tar.gz | tar xz --strip 1 -C "${NO_VNC_HOME}" \
&& wget -qO- https://github.com/novnc/websockify/archive/v0.10.0.tar.gz | tar xz --strip 1 -C "${NO_VNC_HOME}"/utils/websockify \
&& chmod +x -v "${NO_VNC_HOME}"/utils/novnc_proxy
--mount=type=cache,target=/var/cache/apt,from=stage_cache,source=/var/cache/apt \
--mount=type=cache,target=/var/lib/apt,from=stage_cache,source=/var/lib/apt \
DEBIAN_FRONTEND=noninteractive apt-get install -y ${ARG_APT_NO_RECOMMENDS:+--no-install-recommends} \
python3-numpy \
&& mkdir -p "${NOVNC_HOME}"/utils/websockify \
&& wget -qO- https://github.com/novnc/noVNC/archive/v1.3.0.tar.gz | tar xz --strip 1 -C "${NOVNC_HOME}" \
&& wget -qO- https://github.com/novnc/websockify/archive/v0.10.0.tar.gz | tar xz --strip 1 -C "${NOVNC_HOME}"/utils/websockify \
&& chmod +x -v "${NOVNC_HOME}"/utils/novnc_proxy

### add 'index.html' for choosing noVNC client
RUN echo -e \
Expand All @@ -165,9 +169,9 @@ RUN echo -e \
" <p><a href=\"vnc.html\">noVNC Full Client</a></p>\n" \
" </body>\n" \
"</html>" \
> "${NO_VNC_HOME}"/index.html
> "${NOVNC_HOME}"/index.html

EXPOSE ${NO_VNC_PORT}
EXPOSE ${NOVNC_PORT}


###################
Expand Down
24 changes: 19 additions & 5 deletions docker/src/xfce-startup/vnc_startup.rc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ start_vnc () {
rm -rfv /tmp/.X*-lock /tmp/.X11-unix &> "${_vnc_log}"
fi

if [ -n "${_verbose}" ] ; then
echo "Starting VNC"
echo "vncserver ${DISPLAY} &> ${_vnc_log}"
fi

### VNC startup (in the background)
vncserver "${DISPLAY}" &> "${_vnc_log}" &

Expand All @@ -89,20 +94,29 @@ start_vnc () {
if [ "${_arg_skip_novnc}" == "off" ] ; then

### noVNC is not necessarily installed
if [ -n "${NO_VNC_HOME}" ] || [ -d "${NO_VNC_HOME}/utils/websockify" ] ; then
if [ -n "${NOVNC_HOME}" ] || [ -d "${NOVNC_HOME}/utils/websockify" ] ; then

### noVNC requirements
if [ -n "${NO_VNC_PORT}" ] ; then
if [ -n "${NOVNC_PORT}" ] ; then

if [ -n "${_verbose}" ] ; then
echo "Starting noVNC"
echo "${NOVNC_HOME}/utils/novnc_proxy --vnc localhost:${VNC_PORT} --listen ${NOVNC_PORT} ${NOVNC_HEARTBEAT:+--heartbeat ${NOVNC_HEARTBEAT}} &> ${_novnc_log}"
fi

### noVNC startup (in the background)
"${NO_VNC_HOME}"/utils/novnc_proxy --vnc localhost:${VNC_PORT} --listen ${NO_VNC_PORT} &> "${_novnc_log}" &
"${NOVNC_HOME}"/utils/novnc_proxy \
--vnc localhost:${VNC_PORT} \
--listen ${NOVNC_PORT} \
${NOVNC_HEARTBEAT:+--heartbeat ${NOVNC_HEARTBEAT}} \
&> "${_novnc_log}" &

if [ -n "${_verbose}" ] ; then
echo "noVNC started on TCP port '${NO_VNC_PORT}'"
echo "noVNC started on TCP port '${NOVNC_PORT}' ${NOVNC_HEARTBEAT:+with heartbeat ${NOVNC_HEARTBEAT} seconds}"
echo "Connect via web browser"
fi
else
cleanup "ERROR: Environment variable 'NO_VNC_PORT' is not set."
cleanup "ERROR: Environment variable 'NOVNC_PORT' is not set."
fi
else
if [ -n "${_verbose}" ] ; then echo "WARNING: noVNC is not available." ; fi
Expand Down

0 comments on commit 3a55f2c

Please sign in to comment.