Deploying Bokeh app on Google App Engine (GAE) with Docker

Hi,

I am working on a project that involves deploying a Bokeh server on Google App Engine (GAE). I have seen @BryceWayne discussion with @Bryan trying to get bokeh server to work with Flask.

I have taken an alternative approach, by packaging the Bokeh app in a container, like the demo.bokeh.org. After a couple of hours of reading up on how GAE works, I have got it to work by adding the following app.yaml:

runtime: custom
env: flex

And two changes in the Dockerfile

  • EXPOSE 8080 as this is the port GAE listens to (I have removed ports 5006 and 80 just to be sure)
  • CMD bokeh serve --port 8080 ... (rest unchanged) so Bokeh also listens on 8080.

That did the trick for me, and am happy that for small projects and proof-of-concept stuff I can run a Bokeh app on GAE now. Thought it is useful to share it here for future benefit.

1 Like

@dkapitan This is great information. If you would ever like to write up a small step-by-step “howto” addition to the main docs site, please let me know and I am happy to help/advise.

@Bryan
Happy to contribute to demo.bokeh.org by making a PR with a short how-to in readme.md and an alternative version of the Dockerfile.

Is there anything else you would like me to add, while I am at it?

2 Likes

This is great news! I was just about to post about this again. Do you have a github where I can see the Dockerfile and app.yaml?

@dkapitan The demo.bokeh.org repo is first and foremost to service the deployment of the actual running demo.bokeh.org site. I would like to avoid encumbering it with things not directly related to that deployment. Some other ideas:

  • Put it under https://github.com/bokeh/bokeh/tree/master/docker-tools in the main repo

    In fact this entire subdirectory really needs to be cleaned up. I am not a Docker expert so I don’t really trust my own judgment here. It would be great for an experienced Docker user to re-organize that entire subdirectory in whatever way they deem most useful.

  • Add a section to the Running a Bokeh Server chapter of the User’s Guide.

    This would involve editing the Sphinx docs sources. If the Dockerfile is not large presumably it could just be included whle in the docs (or linked in to from the main repo if the above task is also done)

This would be a great addition to the docs for all users, please let me know what you think and how I can assist.

Hi Bryan,

Thanks for the input. Will have a look at your suggestions. In the meantime, I have forked demo.bokeh.org and made a separate branch: https://github.com/dkapitan/demo.bokeh.org/tree/deploy-gae-flex

Cheers,
Daniel

1 Like

Bad link. Try switching the positions. Thank you though.

Second attempt @BryceWayne:

@Bryan
I feel the second option, i.e. enhancing docker-tools in the source code, is do-able for me. Have just read the DevGuide. It’s not clear to me which Git workflow you use (apart from the hooks). My idea is to fork the repo, make changes in docker-tools and submit a PR? Since I won’t be doing anything with the JS side of things, I can safely skip the build tests, right?

@dkapitan That’s exactly right. The docker-tools directory is fairly isolated from all the rest of things. The only reason you might need to run tests is if you wanted to work on update the “dev” dockerfiles that I think are there. They are probably out of date now that we have switched over to GH CI. But for now what’s there currently could also just be re-organized as-is, into whatever new overall structure you think is appropriate.

Thanks for the update and your work.

I am trying to obtain the minimal working example. If I can figure it out I’ll create a YouTube video.

We’d love to tweet it out :smiley:

Thanks again. I am very close.

Current build error:

Updating service [default] (this may take several minutes)…failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
ERROR: Path for Bokeh server application does not exist: /dashboard.py

My guess is that CMD bokeh serve dashboard.py won’t work in Dockerfile?

Fixed. I had to add the correct path. I will create a canonical example then record a YT video. Thank you @Bryan and @dkapitan!!

My dashboard: https://mlcdashboard-250118.appspot.com/dashboard

1 Like

@BryceWayne that’s great, please let us know when we can tweet something out!

Also, in passing, a short write up, especially if you can link to the code, would be terrific for the Showcase!

I have a quick question about the index.html for demo.bokeh.org and implementing my own. Below is my index.html.

I am trying to add something like the sliders.py server to the index which looks like

![](upload://hulqYwxYktfR8u1HiIxbiILmAcW.png)

A basic demo that has sliders for controlling a plotted trigonometric function

Source code: sliders.py

The issue is the a target="_blank" href="sliders"
img src=“https://static.bokeh.org/sliders_t.png”>
***

Can I replace the href=“sliders” with my file name? For example, href=“dashboard”

@BryceWayne
Not sure if I understand you correctly, but if you want more control on the layout, best way is to use the templating function. This is a good tutorial: “Data Visualization with Bokeh in Python, Part III: Making a Complete Dashboard” by Will Koehrsen https://link.medium.com/dWPUiRks62.

1 Like

This is a good reference. Thank you. My question was about how to link to the Bokeh Dashboard inside the html file; precisely like in your github repo. I deployed my dashboard on GCP/GAE and everything runs great. You really helped a lot.

1 Like