Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
enable Novnc (#73)
Browse files Browse the repository at this point in the history
* 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人 <[email protected]>
  • Loading branch information
Fuseteam and ii64 authored May 12, 2021
1 parent 82ea70f commit 8f069af
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down Expand Up @@ -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, ...

Expand Down
3 changes: 3 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
7 changes: 7 additions & 0 deletions src/docker-2ndboot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/unsudo
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8f069af

Please sign in to comment.