Deployment Overview of Jupyter Notebook on Server¶
Prerequisites and Basic Requirements¶
The deployment requires a Linux-based server environment with the following specifications:
-
Operating System: Ubuntu (compatible with
aptpackage manager). -
Privileges: Root access or
sudoprivileges are required for installation and service management. -
Domain: The server must be associated with the
hostkey.inzone. -
Ports:
-
Internal application port:
8888 -
External HTTPS port:
443
FQDN of the Final Panel¶
The application is accessible via the following Fully Qualified Domain Name (FQDN) format:
notebook<Server ID>.hostkey.in:443
File and Directory Structure¶
The application utilizes the following directory structure for configuration, data, and execution:
-
/opt/data: Root directory for Jupyter data and virtual environment. -
/opt/data/jupyter: Location of the Python virtual environment. -
/root/.jupyter: Location of the Jupyter configuration files. -
/root/nginx: Directory containing the Docker Compose configuration for the proxy. -
/usr/lib/systemd/system/jupyter-notebook.service: Systemd service unit file. -
/home: Mounted volume for user home directories within the proxy container.
Application Installation Process¶
The Jupyter Notebook application is installed using the following steps:
-
A dedicated system user and group named
jupyter(UID/GID:2841) are created. -
Required system packages are installed via
apt: -
python3 -
python3-pip -
jupyter -
python3-virtualenv -
A Python virtual environment is created at
/opt/data/jupyter. -
The following Python packages are installed within the virtual environment:
-
notebook -
voila -
virtualenv -
jupyter-server -
The Jupyter configuration is generated and modified to allow cross-origin requests (
c.ServerApp.allow_origin = '*'). -
A password is generated for the Jupyter Notebook interface.
-
The application is registered as a systemd service named
jupyter-notebook.
Docker Containers and Their Deployment¶
A reverse proxy and SSL termination layer is deployed using Docker Compose. The deployment includes:
-
Image:
jonasal/nginx-certbot:latest -
Restart Policy:
unless-stopped -
Network Mode:
host -
Volumes:
-
nginx_secrets: External volume mapped to/etc/letsencryptfor SSL certificates. -
/data/nginx/user_conf.d: Mapped to/etc/nginx/user_conf.dfor custom Nginx configurations. -
/home: Mapped to/homeinside the container. -
Environment:
-
CERTBOT_EMAIL: Set to[email protected]. -
Configuration File: The Docker Compose file is located at
/root/nginx/compose.yml.
Proxy Servers¶
The application is fronted by an Nginx container running Certbot for SSL management:
-
Service Name:
nginx -
Function: Handles HTTPS traffic on port
443and forwards requests to the internal Jupyter instance. -
SSL: Managed automatically via Certbot.
-
Custom Domains: Configured to serve the
hostkey.inzone with the specific prefix.
Permission Settings¶
File and directory permissions are configured as follows:
-
/opt/data: Owned byjupyter:jupyterwith mode0777. -
/opt/data/jupyter: Owned byjupyter:jupyterwith mode0755. -
/root/nginx: Owned byroot:rootwith mode0644. -
/root/nginx/compose.yml: Owned byroot:rootwith mode0644. -
The Jupyter service runs as the
rootuser and group within the systemd service definition.
Location of Configuration Files and Data¶
Key configuration and data files are located at:
-
Jupyter Config:
/root/.jupyter/jupyter_server_config.jsonand/root/.jupyter/jupyter_notebook_config.py. -
Docker Compose:
/root/nginx/compose.yml. -
Nginx Environment:
/data/nginx/nginx-certbot.env. -
Data Directory:
/opt/data/jupyter/share/jupyter(Notebook working directory). -
PID File:
/run/jupyterlab.pid.
Available Ports for Connection¶
The following ports are utilized for the application:
-
Port 8888: Internal port used by the Jupyter Notebook service.
-
Port 443: External port used for secure HTTPS access via the Nginx proxy.
Starting, Stopping, and Updating¶
The Jupyter Notebook service is managed via systemd. Use the following commands to control the service:
-
Start the service:
-
Stop the service:
-
Restart the service:
-
Enable service on boot:
-
Reload systemd daemon:
To manage the Docker proxy container, navigate to the configuration directory and use Docker Compose commands: