How to ship bokeh server application?

1k views Asked by At

What's the preferred way to deploy an application supposed to be run with bokeh serve --show to other people?

I've only found a 2014 year topic of someone using Vagrant for this aim. Are there any better alternatives?

Update

I need 'offline' mode so that another person could launch it on his/her computer, not web access.

2

There are 2 answers

1
Jack On

So it depends a bit on the structure of what you're building - whether it is combined with something like flask or if you just want the actual plot visible.

First of all, the docs are great but in general:

1) Only the bokeh plot, nothing more:

a) Deploy on Heroku as in this question.

b) Deploy via reverse proxy on some webserver. More detailed examples are available on the linked docs but this is a basic example of an nginx config assuming you are running something like bokeh serve myapp.py --port 5100:

server {
    listen 80 default_server;
        server_name _;
        access_log  /tmp/bokeh.access.log;
        error_log   /tmp/bokeh.error.log debug;

    location / {
        proxy_pass http://127.0.0.1:5100;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host:$server_port;
        proxy_buffering off;
    }

}

If you need ssl with it (likely) there are examples for this as well.

2) Integrated with Flask/Django/Whatever:

In this case you can't use Heroku as the bokeh (tornado) server and flask/etc servers both need to be running separately and Heroku just doesn't support this, so unless you feel like configuring 2 separate apps with one running each its out of the picture.

This leaves you with good ol' reverse proxy funtimes. Difference here is you have to have both processes running (eg with supervisor) and then set up your config file to send these requests where they need to go. If this is the case the mailing list is your best bet for detailed info as it will depend a bit on what you need.

0
Antony Hatchkins On

Packaging it with pyinstaller (http://jishichao.com/2017/01/10/package-a-python-program-to-a-single-executable-file/) seems to be the right approach.

There're certain nuances when packaging bokeh with pyinstaller though. Ticket #1898 (https://github.com/pyinstaller/pyinstaller/issues/1898) lists one of them and gives some clues how to overcome it. It helped to a certain degree, but I haven't succeeded with making a fully-functional exe file using this method yet.