From 8f069af5a170811b822ed6ec5a40f613464d2cc5 Mon Sep 17 00:00:00 2001 From: Rahammetoela Toekiman Date: Wed, 12 May 2021 07:11:40 -0300 Subject: [PATCH] enable Novnc (#73) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add noVNC support (#1) * Feature: noVNC * Fixing env * Fixing stuffs * Typo * Update README.d * Update test script (#2) * Update README and screenshot test * remove unneccesary additions * change ARG to ENV and remove hack * rename the environment variable to enable novnc to "webmode" * add the novnc options to docker-compose * remove unrelated workflow change * fix loading the environment * replace leftover NOVNC with WEBMODE * remove novnc support from todo section * enable webmode by default * add explaination for webmode * set the correct url * start websockify as soon as the vnc server is up and running Co-authored-by: Ii64人 --- .github/workflows/main.yaml | 2 +- Dockerfile | 5 +++++ README.md | 7 ++++++- docker-compose.yml | 3 +++ src/docker-2ndboot.sh | 7 +++++++ src/unsudo | 2 +- 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index cf42c54..6de12cf 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -12,7 +12,7 @@ jobs: # test - run: ./hack/translate-dockerfile-runopt-directive.sh < Dockerfile | DOCKER_BUILDKIT=1 docker build -f - -t aind/aind:local . - run: sudo ./hack/install-kmod.sh - - run: docker run -td --name aind --privileged -p 5900:5900 -v /lib/modules:/lib/modules:ro aind/aind:local + - run: docker run -td --name aind --privileged -p 5900:5900 -p 8080:8080 -e "WEBMODE=1" -v /lib/modules:/lib/modules:ro aind/aind:local - run: timeout 60 sh -exc "until docker exec aind pgrep -f org.anbox.appmgr; do sleep 10; done" # diagnosis - run: docker exec aind ps -ef diff --git a/Dockerfile b/Dockerfile index f2421fb..69dfa33 100644 --- a/Dockerfile +++ b/Dockerfile @@ -90,6 +90,8 @@ RUN apt-get update && \ dbus dbus-user-session systemd systemd-container systemd-sysv \ # X11 xvfb x11vnc \ +# noVNC + websockify novnc \ # WM fvwm xterm \ # debug utilities @@ -113,11 +115,14 @@ ADD src/anbox-container-manager.service /lib/systemd/system/anbox-container-mana RUN systemctl enable anbox-container-manager ADD src/unsudo /usr/local/bin ADD src/docker-2ndboot.sh /home/user + +ENV WEBMODE 0 # Usage: docker run --rm --privileged -v /:/host --entrypoint bash aind/aind -exc "cp -f /install-kmod.sh /host/aind-install-kmod.sh && cd /host && chroot . /aind-install-kmod.sh" ADD hack/install-kmod.sh / VOLUME /var/lib/anbox ENTRYPOINT ["/docker-entrypoint.sh", "unsudo"] EXPOSE 5900 +EXPOSE 8080 HEALTHCHECK --interval=15s --timeout=10s --start-period=60s --retries=5 \ CMD ["pgrep", "-f", "org.anbox.appmgr"] CMD ["/home/user/docker-2ndboot.sh"] diff --git a/README.md b/README.md index 1666890..0055463 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,12 @@ sudo modprobe binder_linux ```bash docker run -td --name aind --privileged -p 5900:5900 -v /lib/modules:/lib/modules:ro aind/aind +``` + +to run the container with novnc support the environment variable WEBMODE canbe set with the following command +the container will be accessible via the browser at http://localhost:8080/vnc.html +```bash +docker run -td --name aind --privileged -p 8080:8080 -e "WEBMODE=1" -v /lib/modules:/lib/modules:ro aind/aind docker exec aind cat /home/user/.vnc/passwdfile ``` @@ -158,7 +164,6 @@ aind is expected to be used in conjunction with encryption of the client device, ## TODOs * Map different UID range per containers -* Support remote connection from phones and tablets, ideally using Web browsers (noVNC?). * Better touch screen experience * Redirect camera, notifications, ... diff --git a/docker-compose.yml b/docker-compose.yml index 2ecbe96..b118b1a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,7 +4,10 @@ services: image: 'aind/aind' privileged: true tty: true + environment: + - WEBMODE=1 ports: - '5900:5900' + - '8080:8080' volumes: - '/lib/modules:/lib/modules:ro' diff --git a/src/docker-2ndboot.sh b/src/docker-2ndboot.sh index 6219d6c..0ef8531 100755 --- a/src/docker-2ndboot.sh +++ b/src/docker-2ndboot.sh @@ -50,6 +50,12 @@ if [ $INHERIT_DISPLAY -eq 0 ]; then fvwm & fi +if [ $WEBMODE = "1" ]; then + echo "running websockify..." + websockify -D --web /usr/share/novnc/ 0.0.0.0:8080 127.0.0.1:5900 + echo "websockify -> $?" +fi + if ! systemctl is-system-running --wait; then systemctl status --no-pager -l anbox-container-manager journalctl -u anbox-container-manager --no-pager -l @@ -79,6 +85,7 @@ fi [ -n "${POST_SESSION_SCRIPT:-}" ] && . $POST_SESSION_SCRIPT + # done figlet "Ready" echo "Hint: the password is stored in $HOME/.vnc/passwdfile" diff --git a/src/unsudo b/src/unsudo index 8fd3657..ce0203e 100755 --- a/src/unsudo +++ b/src/unsudo @@ -5,7 +5,7 @@ shift cdr=$@ # machinectl requires absolute path params=("shell") -avail_envs="INHERIT_DISPLAY DISPLAY SESSION_MANAGER_ARGS POST_SESSION_SCRIPT" +avail_envs="INHERIT_DISPLAY DISPLAY SESSION_MANAGER_ARGS POST_SESSION_SCRIPT WEBMODE" for name in $avail_envs; do [ -n "${!name:-}" ] && params+=("--setenv=$name=${!name}") done