How to containerize Jupyter Book#

Note

The following assumes you have documentation built with Jupyter Book already. If you do not the Jupyter Book documentation here is a great place to start.

CISL theme template

The repository here can be cloned to create a starting point with custom CSS and HTML already in place for a CISL inspired theme. The web content associated with that repository can be viewed here. All customizations were done on top of the Project Pythia theme. The Project Pythia team provides excellent documentation for this theme here.

Jupyter Book content can be hosted via a container quite easily. After running jupyter-book build . there is a _build/ directory that contains an html/ folder with all the necessary files for a website. A Dockerfile will utilize an Apache web server image while copying the required files to the appropriate folder that Apache serves content out of. An example of what this Dockerfile would look can be seen below:

# Use the Apache HTTP server image
FROM httpd:2.4

# Copy HTML files created by `jupyter-book build .` in to directory apache serves out of
COPY _build/html/ /usr/local/apache2/htdocs/

It’s really just 2 lines required to define the image. With that Dockerfile created an image can be built with a command like docker build -t image-name path/2/Dockerfile/dir/.. The image can be run and tested locally with a command like docker run -p 80:80 image-name:latest where the web content can then be accessed at http://localhost.