Post

Open Source Alternative To Notebooklm

Welcome, experienced sysadmins and DevOps engineers! Today we will guide you through setting up a self-hosted, open-source solution for notebook-based data analysis and collaboration—a viable alternative to proprietary tools like.

# Open Source Alternative to NotebookLM: Self-Hosting with JupyterHub and ZeroNotebook

Welcome, experienced sysadmins and DevOps engineers! Today we will guide you through setting up a self-hosted, open-source solution for notebook-based data analysis and collaboration—a viable alternative to proprietary tools like NotebookLM. We’ll be using JupyterHub and ZeroNotebook, which are powerful, flexible tools for creating infrastructure automation in the realm of data science and DevOps.

Prerequisites

To follow along with this tutorial, ensure you have the following prerequisites:

  1. A modern Linux distribution (e.g., Ubuntu 20.04 or CentOS 8)
  2. Docker CE version 19.03 or higher installed
  3. Docker Compose version 1.26 or higher installed

Setting Up JupyterHub with ZeroNotebook

Step 1: Install Docker and Docker Compose

1
2
3
4
5
6
7
8
9
10
11
12
# Ubuntu/Debian
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER

# CentOS/RHEL
yum install docker-ce-19.03 -y
sudo systemctl enable --now docker
sudo usermod -aG docker $USER

# Install Docker Compose
curl -Lo /usr/local/bin/docker-compose $(curl -L https://github.com/docker/compose/releases/download/1.26.2/docker-compose-Linux-x86_64)
chmod +x /usr/local/bin/docker-compose

Step 2: Create JupyterHub Configuration Files

Create a directory for the project and navigate into it.

1
mkdir jupyterhub && cd jupyterhub

Initialize a new jupyter_notebook_config.py file with the following content:

1
2
3
4
5
6
c = get_config()

# Configure JupyterHub to use ZeroNotebook by default
c.NotebookApp.default_url = '/zero'
c.NotebookApp.open_browser = False
c.JupyterHub.singleuser_notebook_path='%(user_name)s/notebooks'

Create a docker-compose.yml file with the following content:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
version: '3.7'
services:
  jupyterhub:
    image: jupyterhub/zero:latest
    container_name: jupyterhub
    environment:
      JUPYTERHUB_CONFIG_OVERWRITE=${PWD}/jupyter_notebook_config.py
      JUPYTER_NOTEBOOK_PORT=8000
    volumes:
      - .:/home/jovyan
      - jupyterhub-data:/app
    ports:
      - '8000:8000'
    networks:
      - zero
  proxy:
    image: jupyterhub/zero-proxy:latest
    container_name: jupyterhub-proxy
    environment:
      JUPYTERHUB_API_TOKEN=$JUPYTERHUB_API_TOKEN
      PROXY_REVERSE_X_FORWARDED_HOST=jupyterhub.localhost
    volumes:
      - .:/home/jovyan
      - proxy-data:/app
    ports:
      - '8888:8888'
      - '4001:4001'
      - '8001:8001'
    networks:
      - zero
  zero:
    image: jupyterhub/zeronotebook:latest
    container_name: zeronotebook
    environment:
      JUPYTERHUB_API_TOKEN=$JUPYTERHUB_API_TOKEN
    volumes:
      - .:/home/jovyan
      - zero-data:/app
    networks:
      - zero
networks:
  zero:
    driver: bridge
volumes:
  jupyterhub-data:
  proxy-data:
  zero-data:

Step 3: Start JupyterHub

Start the Docker Compose stack with the following command:

1
docker-compose up -d

Access your self-hosted JupyterHub instance by visiting http://jupyterhub.localhost.

Troubleshooting

If you encounter issues, ensure that Docker and Docker Compose are properly installed, and check the logs of each container for any error messages:

1
2
3
docker logs jupyterhub
docker logs jupyterhub-proxy
docker logs zeronotebook

Conclusion

In this tutorial, we demonstrated a practical approach to setting up a self-hosted, open-source alternative to NotebookLM using JupyterHub and ZeroNotebook. This configuration provides an excellent foundation for data analysis and collaboration in your home lab or production environment. Happy DevOps-ing!

This post is licensed under CC BY 4.0 by the author.