This blog sets up Jupyter Notebook on an OCI computer machine using docker. It then shows you how to configure your credentials to call the OCI Generative AI service. It also describes configuration of SSL and custom domains to access your notebook.
You can use this blog for installing Jupyter Notebook locally on your laptop too.
Note: Chicago or Frankfurt regions only support Generative AI at time of writing.
Setup Environment
HTTPS / SSL / Custom Domain Instructions
Only follow these instructions if you want HTTPS/SSL
Obtain your Origin Certificate and Key from Cloudflare (or your Domain Registrar) e.g SSL/TLS > Origin Server > Create Certificate
Create your key
nano notebook.key
paste in your key.
nano notebook.crt
Paste in the cert
OPTIONAL: If you don't have a key, create a key pair...
openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout notebook.key -out notebook.crt
Start the container which will first download the image
docker create -it --name jupyter -p 10000:8888 \ -e GEN_CERT=no \ quay.io/jupyter/scipy-notebook:latest \ start-notebook.py \ --ServerApp.keyfile=/etc/ssl/certs/notebook.key \ --ServerApp.certfile=/etc/ssl/certs/notebook.crt
Copy the keys to the container
docker cp notebook.key jupyter:/etc/ssl/certs/notebook.key docker cp notebook.crt jupyter:/etc/ssl/certs/notebook.crt
Star the jupyter container
docker start jupyter
Now go to your NGINX Proxy Manager Panel - Here is a guide if you've not set it up
Create a Proxy host like this. I had to use the local IP address of the compute box for some reason as it wasn't resolving. Also, Websockets Support must be on.
Then choose your Origin Certificate
HTTP Instructions
Only follow these instructions if you want HTTP not HTTPS
Start the container which will first download the image
docker run -d -it --name jupyter -p 10000:8888 quay.io/jupyter/scipy-notebook:latest
Access Jupyter
Now the container is running, list the Logs.
docker logs jupyter
Gives you the URL including the token
[I 2024-06-09 14:55:38.236 ServerApp] http://127.0.0.1:8888/lab?token=abc
Open Ports 10000 using this guide e.g
sudo firewall-cmd --permanent --zone=public --add-port=10000/tcp sudo firewall-cmd --reload
Then add an Add Ingress Rule to the Default Security List also by following this guide
Put the URL in the browser (without the token), but make sure to change the port from 8888 to 10000 and your IP (or use localhost)
To fetch your IP type
curl ipconfig.io
and then format the URL like this
http://19.19.19.19:10000/lab
or like this
http://localhost:10000/lab
or if using SSL
https://my-custom-domain/lab
Paste the URL into your browser
Paste in the token (from the logs) and set a new password
You can now use your password to log in the future rather than the token.
Click on Terminal
Install OCI SDK
pip install oci
Create an .oci folder to hold the credentials
mkdir ~/.oci
Create a new PEM file in Nano (we wont edit it just yet)
nano ~/.oci/oci_api_key.pem
In OCI, Click Profile > My Profile
Click API Keys > Add API Key > Download API Key
Don't touch anything in OCI yet, Open the downloaded file in VSCode & copy it to Clipboard
Back in Jupyter Console, paste it in to Nano and use CTRL+X to save and exit.
Back in OCI press Add
Don't touch anything in OCI yet, keep the window open
Back in Jupyter Console, type
nano ~/.oci/config
Copy the info from OCI to clipboard
Paste in to Nano
Change the last line to
key_file=~/.oci/oci_api_key.pem
CTRL+X to save and exit nano
Testing
Go to the OCI Generative Playground
Type in a query and hit submit
Give me 5 fun bullet point facts about Leeds United
Click View Code > Python > Copy Code
In Jupyter, click Python3 (ipykernal) icon
Paste the code directly in
Click the Run/Play Icon or shift-enter to run
Enjoy
Next Steps
Dracula Theme
Of course you need Dracula Theme.
Install Dracula Theme in Terminal
pip install JLDracula
Refresh the Browser
Settings > Themes > JLDracula
ENJOY!
Whats the picture? It's Adel Dam Nature Reserve, Leeds. I tried to spot a real Kingfisher, but I failed.