Base repo for running Jupyter Notebooks on the Jamsocket platform
- Log in to Jamsocket and create a new service called
jupyter-notebook
. (Sign up for a Jamsocket account if you don’t already have one. You can do everything listed here on the free plan.) - Reach out to us on Discord or by email to ask us to enable Jamsocket compatibility mode for that service. (This will soon be exposed directly in the web UI, but it's a manual step for now.)
- Fork this repo as
jupyter-notebook
to your own GitHub account. Note that the name of the repo should match the name of the service, but you can use another name as long as they both match. - Set your Jamsocket account name as the
JAMSOCKET_ACCOUNT
value in your GitHub secrets. - Generate an access token at app.jamsocket.com/settings and set it as the
JAMSOCKET_TOKEN
value in your GitHub secrets. - Push your repo to your GitHub account, and your Jupyter Notebook container will be automatically built and pushed to the Jamsocket service you selected.
- Use the Jamsocket API to spawn instances of your notebook. It will return a URL that you can use to access the notebook.
You can customize the initial notebook(s) and Python packages as follows:
- Add your notebook(s) to the
/notebook
directory. - Add your notebook's python dependencies to
requirements.txt
(alternatively, if you preferpipenv
, add them withpipenv install
and then runpipenv run freeze
). - Replace
/notebooks/hello-jamsocket.ipynb
inDockerfile
with the path to the notebook you'd like to be automatically loaded. If you want the user to see a file listing of the/notebooks
directory by default, remove that line entirely. - Run
./freeze.sh
to create afreeze.txt
file fromrequirements.txt
. This pins the version of all of the dependencies of the libraries inrequirements.txt
.
docker build -t jupyter-notebook .
docker run -p 8080:8080 --env PORT=8080 -it jupyter-notebook
open localhost:8080
By default, this runs the jupyter notebook
command. If you want to run the jupyter lab
command instead, you can set the JUPYTER_SUBCOMMAND
environment variable to lab
.