Skip to content

Commit af50335

Browse files
feat: add jupyter notebook and lab to ide docs (#1050)
* feat: add jupyter notebook and lab to ide docs * linting and table of contents at top * minor typographical mistakes; refining wording * chore: adjust pip3 install jupyterlab in Dockerfiles * chore: split our port forwarding as a 3rd way to access JupyterLab * chore: wording refactor Co-authored-by: Eric Paulsen <ericpaulsen@coder.com>
1 parent 2aa0fe7 commit af50335

File tree

4 files changed

+126
-0
lines changed

4 files changed

+126
-0
lines changed
60.9 KB
Loading
80.3 KB
Loading
394 KB
Loading

workspaces/editors.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ There are several primary ways you can connect an IDE to your Coder workspace:
1313
JetBrains Projector
1414
1. [JetBrains' Code With Me](editors.md#code-with-me)
1515
1. [Multiple JetBrains IDEs](editors.md#multiple-jetbrains-ides)
16+
1. [Jupyter Notebook](editors.md#jupyter-notebook)
17+
1. [JupyterLab](editors.md#jupyterlab)
1618
1. [RStudio](editors.md#rstudio)
1719
1. _Any_ local editor with
1820
[1-way file synchronization](../cli/file-sync.md#one-way-file-sync) or
@@ -313,6 +315,130 @@ We have provided
313315
[detailed configuration steps](../guides/customization/multiple-jetbrains-ides.md)
314316
for setting up your custom image and configure script.
315317

318+
## Jupyter Notebook
319+
320+
Jupyter Notebook is the original web IDE for creating Notebooks used in data
321+
science, machine learning and analytics projects. By default, any Coder
322+
workspace with the Jupyter project installed (in `/usr/local/bin/jupyter`)
323+
will render the icon to launch Jupyter Notebook.
324+
325+
![Jupyter Notework](../assets/workspaces/jupyter-notebook-icon.png)
326+
327+
To use Jupyter Notebook in a Coder workspace, build a Dockerfile with Jupyter
328+
project installed as shown below:
329+
330+
```Dockerfile
331+
# Dockerfile to install Jupyter Notebook
332+
FROM codercom/enterprise-base:ubuntu
333+
334+
USER root
335+
336+
RUN pip3 install jupyter notebook
337+
338+
USER coder
339+
```
340+
341+
## JupyterLab
342+
343+
JupyterLab is the next-generation web-based IDE for data science and Python
344+
using documents called Notebooks.
345+
346+
![JupyterLab](../assets/workspaces/jupyterlab-opened.png)
347+
348+
There are three methods to install and access JupyterLab in Coder. All require
349+
JupyterLab to be installed in the Dockerfile via `pip3 install jupyterlab`.
350+
351+
The first method renames the `jupyter` binary and copies a new `jupyter` that
352+
adjusts the arguments passed to the `jupyter` binary to tell Coder to launch
353+
JupyterLab instead of Notebook.
354+
355+
```Dockerfile
356+
FROM codercom/enterprise-base:ubuntu
357+
358+
USER root
359+
360+
RUN pip3 install jupyterlab
361+
RUN pip3 install jupyter notebook
362+
363+
RUN mv /usr/local/bin/jupyter /usr/local/bin/jupyter.py
364+
365+
COPY jupyter /usr/local/bin/jupyter
366+
367+
USER coder
368+
```
369+
370+
Below is an example `jupyter` script with the lab arguments. This file must
371+
be located in the same directory as the Dockerfile to be copied during `docker build`
372+
373+
```sh
374+
#!/bin/bash
375+
# Replace all "NotebookApp" settings with ServerApp settings.
376+
args=${@//LabApp/"ServerApp"}
377+
# Replace 'notebook' with 'lab' to launch juypter lab
378+
args=${args/notebook/"lab"}
379+
380+
jupyter.py ${args}
381+
```
382+
383+
The second method to run JupyterLab is with a dev URL and launching
384+
JupyterLab via `supervisord` in the `configure` script. The benefit of this
385+
approach is it is completely independent of Coder's IDE launching mechanism
386+
and relies only on a generic dev URL.
387+
388+
![JupyterLab as a dev URL](../assets/workspaces/jupyterlab-as-devurl.png)
389+
390+
```Dockerfile
391+
FROM codercom/enterprise-base:ubuntu
392+
393+
USER root
394+
395+
RUN pip3 install jupyterlab
396+
RUN pip3 install jupyter notebook
397+
398+
# configure script to create a dev URL and launch JupyterLab
399+
COPY ["configure", "/coder/configure"]
400+
RUN chmod +x /coder/configure
401+
402+
# install supervisord
403+
RUN apt-get update && apt-get install -y supervisor
404+
RUN mkdir -p /var/log/supervisor
405+
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
406+
407+
# change back to the coder user
408+
USER coder
409+
```
410+
411+
The `configure` script installs `supervisord`
412+
413+
```sh
414+
#!/bin/bash
415+
416+
echo 'create dev URL for JupyterLab'
417+
coder urls create $CODER_WORKSPACE_NAME 8888 --name jupyterlab
418+
419+
echo 'start supervisord and JupyterLab'
420+
sudo /usr/bin/supervisord
421+
```
422+
423+
The `supervisord.conf` launches JupyterLab. This file must be located in the
424+
same directory as the Dockerfile to be copied during `docker build`
425+
426+
```sh
427+
[supervisord]
428+
nodaemon=false
429+
environment=HOME=/home/coder
430+
431+
[program:jupyterlab]
432+
command=/usr/local/bin/jupyter lab --ip='*' --NotebookApp.token='' --NotebookApp.password=''
433+
user=coder
434+
directory=/home/coder
435+
```
436+
437+
The third method to access JupyterLab is locally using the SSH port forward
438+
command: `ssh -L 8888:localhost:8888 coder.jupyterlab`. Alternatively, you can
439+
use the Coder CLI to port forward using: `coder tunnel jupyterlab 8888 8888`.
440+
Now, open a local browser and navigate to `https://localhost:8888`.
441+
316442
## RStudio
317443

318444
Coder supports [RStudio](rstudio.com). To create a workspace that lets you use

0 commit comments

Comments
 (0)