Skip to content

Commit

Permalink
fixed integration of VNC with Ubuntu 20.04
Browse files Browse the repository at this point in the history
  • Loading branch information
afdaniele committed Sep 20, 2020
1 parent 7e6f398 commit c94c09e
Show file tree
Hide file tree
Showing 25 changed files with 2,794 additions and 2,062 deletions.
42 changes: 25 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# parameters
ARG REPO_NAME="dt-gui-tools"
ARG DESCRIPTION="Provides access to GUI-based ROS tools (e.g., rviz, rqt_image_view)"
ARG DESCRIPTION="Provides access to GUI-based tools (e.g., rviz, rqt_image_view)"
ARG MAINTAINER="Andrea F. Daniele ([email protected])"
# pick an icon from: https://fontawesome.com/v4.7.0/icons/
ARG ICON="desktop"

# novnc and websockify versions to use
ARG NOVNC_VERSION="35dd3c2"
ARG NOVNC_VERSION="9fe2fd0"
ARG WEBSOCKIFY_VERSION="3646575"

# ==================================================>
Expand Down Expand Up @@ -61,9 +61,6 @@ RUN pip3 install --use-feature=2020-resolver -r ${REPO_PATH}/dependencies-py3.tx
# copy the source code
COPY ./packages "${REPO_PATH}/packages"

# get the image_pipeline
RUN git clone https://github.com/ros-perception/image_pipeline.git

# build packages
RUN . /opt/ros/${ROS_DISTRO}/setup.sh && \
catkin build \
Expand All @@ -90,18 +87,13 @@ LABEL org.duckietown.label.module.type="${REPO_NAME}" \
# <== Do not change the code above this line
# <==================================================

## Python2 pip
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py &&\
python get-pip.py &&\
rm get-pip.py

## nvidia-container-runtime
ENV NVIDIA_VISIBLE_DEVICES ${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES ${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics

# install ffmpeg
COPY assets/vnc/install-ffmpeg /tmp/
RUN /tmp/install-ffmpeg ${ARCH}
# configure ffmpeg
RUN mkdir /usr/local/ffmpeg \
&& ln -s /usr/bin/ffmpeg /usr/local/ffmpeg/ffmpeg

# install backend dependencies
COPY assets/vnc/install-backend-deps /tmp/
Expand All @@ -119,16 +111,18 @@ COPY assets/vnc/image /
## with QEMU enabled.
##
##
FROM ubuntu:xenial as builder
FROM ubuntu:focal as builder

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
curl \
git \
ca-certificates \
git
gnupg \
patch

# nodejs
RUN curl -sL https://deb.nodesource.com/setup_9.x | bash - \
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - \
&& apt-get install -y \
nodejs

Expand All @@ -152,7 +146,8 @@ RUN git clone https://github.com/novnc/websockify /src/web/static/websockify \
COPY assets/vnc/web /src/web
RUN cd /src/web \
&& yarn \
&& npm run build
&& yarn build
RUN sed -i 's#app/locale/#novnc/app/locale/#' /src/web/dist/static/novnc/app/ui.js
##
##
#### <= Substep: Frontend builder
Expand All @@ -162,5 +157,18 @@ RUN cd /src/web \
FROM BASE
COPY --from=builder /src/web/dist/ /usr/local/lib/web/frontend/

# make websockify executable
RUN ln -sf /usr/local/lib/web/frontend/static/websockify \
/usr/local/lib/web/frontend/static/novnc/utils/websockify \
&& chmod +x /usr/local/lib/web/frontend/static/websockify/run

# configure novnc
ENV HTTP_PORT 8087

# get the image_pipeline (this is needed to avoid issues with python2 shebang)
RUN git clone https://github.com/ros-perception/image_pipeline.git

# build packages
RUN . /opt/ros/${ROS_DISTRO}/setup.sh && \
catkin build \
--workspace ${CATKIN_WS_DIR}/
76 changes: 43 additions & 33 deletions assets/vnc/image/etc/nginx/sites-enabled/default
Original file line number Diff line number Diff line change
@@ -1,42 +1,52 @@
server {
listen 80 default_server;
# listen [::]:80 default_server ipv6only=on;
# listen [::]:80 default_server ipv6only=on;

#_SSL_PORT_#listen 443 ssl default_server;
#_SSL_PORT_#listen [::]:443 ssl default_server ipv6only=on;
#_SSL_PORT_#ssl_certificate /etc/nginx/ssl/nginx.crt;
#_SSL_PORT_#ssl_certificate_key /etc/nginx/ssl/nginx.key;
#_SSL_PORT_#listen 443 ssl default_server;
#_SSL_PORT_#listen [::]:443 ssl default_server ipv6only=on;
#_SSL_PORT_#ssl_certificate /etc/nginx/ssl/nginx.crt;
#_SSL_PORT_#ssl_certificate_key /etc/nginx/ssl/nginx.key;

#_HTTP_PASSWORD_#auth_basic "Private Property";
#_HTTP_PASSWORD_#auth_basic_user_file /etc/nginx/.htpasswd;
#_HTTP_PASSWORD_#auth_basic "Private Property";
#_HTTP_PASSWORD_#auth_basic_user_file /etc/nginx/.htpasswd;

root /usr/local/lib/web/frontend/;
index index.html index.htm;

location ~ ^/api {
try_files $uri @api;
}

location = /websockify {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:6081;
}

location @api {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:6079;
max_ranges 0;
}

location @proxy {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:6081;
max_ranges 0;
}
#_RELATIVE_URL_ROOT_location /_RELATIVE_URL_ROOT_/ {
#_RELATIVE_URL_ROOT_ rewrite /_RELATIVE_URL_ROOT_/(.*) /$1 break;
#_RELATIVE_URL_ROOT_ root /usr/local/lib/web/frontend/;
#_RELATIVE_URL_ROOT_}

location ~ .*/(api/.*|websockify) {
try_files $uri @api$http_upgrade;
}

location / {
rewrite /approot/(.*) /$1 break;
root /usr/local/lib/web/frontend/;
}

location @apiwebsocket {
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 break;
proxy_connect_timeout 7d;
proxy_send_timeout 7d;
proxy_read_timeout 7d;
proxy_buffering off;

proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:6081;
}

location @api {
#_RELATIVE_URL_ROOT_rewrite /_RELATIVE_URL_ROOT_/(.*) $1 break;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
max_ranges 0;
proxy_pass http://127.0.0.1:6079;
}
}

19 changes: 10 additions & 9 deletions assets/vnc/image/etc/supervisor/conf.d/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,34 @@ stderr_logfile_maxbytes=0
[group:x]
programs=xvfb,wm,lxpanel,pcmanfm,x11vnc,novnc

[program:xvfb]
priority=10
command=/usr/local/bin/xvfb.sh
stopsignal=KILL

[program:wm]
priority=15
command=/usr/bin/openbox
environment=DISPLAY=":99",HOME="/root",USER="root"
environment=DISPLAY=":1",HOME="/root",USER="root"

[program:lxpanel]
priority=15
directory=%HOME%
command=/usr/bin/lxpanel --profile LXDE
user=%USER%
environment=DISPLAY=":99",HOME="%HOME%",USER="%USER%"
environment=DISPLAY=":1",HOME="%HOME%",USER="%USER%"

[program:pcmanfm]
priority=15
directory=%HOME%
command=/usr/bin/pcmanfm --desktop --profile LXDE
user=%USER%
environment=DISPLAY=":99",HOME="%HOME%",USER="%USER%"
stopwaitsecs=3
environment=DISPLAY=":1",HOME="%HOME%",USER="%USER%"

[program:xvfb]
priority=10
command=/usr/local/bin/xvfb.sh
stopsignal=KILL

[program:x11vnc]
priority=20
command=x11vnc -display :99 -xkb -forever -shared -repeat
command=x11vnc -display :1 -xkb -forever -shared -repeat -capslock

[program:novnc]
priority=25
Expand Down
69 changes: 0 additions & 69 deletions assets/vnc/image/setup-vnc.sh

This file was deleted.

8 changes: 0 additions & 8 deletions assets/vnc/image/usr/local/bin/chromium-browser-sound.sh

This file was deleted.

2 changes: 1 addition & 1 deletion assets/vnc/image/usr/local/bin/xvfb.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/sh

exec /usr/bin/Xvfb :99 -screen 0 1024x768x16
exec /usr/bin/Xvfb :1 -screen 0 1024x768x24
31 changes: 15 additions & 16 deletions assets/vnc/image/usr/local/lib/web/backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
backports.ssl-match-hostname==3.5.0.1
certifi==2018.1.18
backports.ssl-match-hostname==3.7.0.1
certifi==2019.9.11
chardet==3.0.4
click==6.7
Flask==0.12.2
Click==7.0
Flask==1.1.1
Flask-Login==0.4.1
gevent==1.2.2
gevent==1.4.0
gevent-websocket==0.10.1
greenlet==0.4.13
idna==2.6
itsdangerous==0.24
Jinja2==2.10
MarkupSafe==1.0
meld3==1.0.2
requests==2.18.4
six==1.11.0
supervisor==3.2.0
urllib3==1.22
greenlet==0.4.15
idna==2.8
itsdangerous==1.1.0
Jinja2==2.10.3
MarkupSafe==1.1.1
meld3==2.0.0
requests==2.22.0
six==1.12.0
urllib3==1.25.6
websocket-client==0.47.0
Werkzeug==0.14.1
Werkzeug==0.16.0
5 changes: 3 additions & 2 deletions assets/vnc/image/usr/local/lib/web/backend/run.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import (
absolute_import, division, print_function, with_statement
)
Expand Down Expand Up @@ -74,7 +74,7 @@ def find_files(directory="./"):

def run_server():
import socket
from gevent.wsgi import WSGIServer
from gevent.pywsgi import WSGIServer
from vnc.app import app

# websocket conflict: WebSocketHandler
Expand Down Expand Up @@ -114,6 +114,7 @@ def run_server():
)
logging.getLogger("werkzeug").setLevel(logging.WARNING)
log = logging.getLogger('novnc2')

entrypoint()


Expand Down
Loading

0 comments on commit c94c09e

Please sign in to comment.