From 6858223587064aead1991b91d4877bbc0f707199 Mon Sep 17 00:00:00 2001 From: Greg Werner Date: Wed, 21 Aug 2024 11:49:47 -0400 Subject: [PATCH] feat: Add node notebooks (#1) Signed-off-by: Greg Werner --- Makefile | 7 +++- deno-notebook/Dockerfile | 40 ++++++++++++++++++ deno-notebook/setup-scripts/kernel-deno.json | 12 ++++++ node-notebook/Dockerfile | 42 +++++++++++++++++++ node-notebook/setup-scripts/kernel-tslab.json | 1 + python-notebook/Dockerfile | 34 +++++++++++---- python-notebook/requirements.txt | 1 + 7 files changed, 128 insertions(+), 9 deletions(-) create mode 100644 deno-notebook/Dockerfile create mode 100644 deno-notebook/setup-scripts/kernel-deno.json create mode 100644 node-notebook/Dockerfile create mode 100644 node-notebook/setup-scripts/kernel-tslab.json diff --git a/Makefile b/Makefile index 3a0b59c..f15e037 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ # Use bash for inline if-statements in target SHELL:=bash -TAG:=julia-1.6.1 +TAG:=latest OWNER:=illumidesk VENV_NAME?=venv VENV_BIN=$(shell pwd)/${VENV_NAME}/bin @@ -13,7 +13,10 @@ VENV_ACTIVATE=. ${VENV_BIN}/activate PYTHON=${VENV_BIN}/python3 # Need to list the images in build dependency order -ALL_STACKS:=umich-notebook +ALL_STACKS:=:= \ + python-notebook \ + deno-notebook \ + node-notebook ALL_IMAGES:=$(ALL_STACKS) diff --git a/deno-notebook/Dockerfile b/deno-notebook/Dockerfile new file mode 100644 index 0000000..fef3792 --- /dev/null +++ b/deno-notebook/Dockerfile @@ -0,0 +1,40 @@ +# Based mostly off of: +# https://github.com/jupyter/docker-stacks/blob/main/images/julia-notebook +ARG REGISTRY=quay.io +ARG OWNER=jupyter +ARG BASE_CONTAINER=$REGISTRY/$OWNER/minimal-notebook +FROM $BASE_CONTAINER + +ENV NB_UID=1000 +ENV NB_GID=100 + +# Fix: https://github.com/hadolint/hadolint/wiki/DL4006 +# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014 +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +USER "${NB_USER}" + +# Install Jupyter Console and Kernel Gateway +RUN pip install jupyter-console jupyter_kernel_gateway + +# Install deno +RUN curl -fsSL https://deno.land/x/install/install.sh | sh \ + && "${HOME}/.deno/bin/deno" jupyter --unstable --install \ + && mv "${HOME}/.deno/bin/deno" "${CONDA_DIR}/bin" \ + && rm -Rf "${HOME}/.deno/bin/deno" + +RUN rm -Rf "${HOME}/.local/share/jupyter/kernels/deno" \ + && mkdir -p "${CONDA_DIR}/share/jupyter/kernels/deno" +COPY --chown=${NB_UID}:${NB_GID} "setup-scripts/kernel-deno.json" "${CONDA_DIR}/share/jupyter/kernels/deno/kernel.json" + +# update permissions as root +USER root +RUN fix-permissions /etc/jupyter/ \ + && fix-permissions "${CONDA_DIR}" \ + && fix-permissions "${HOME}" + +USER "${NB_USER}" + +WORKDIR "${HOME}" + +CMD ["jupyter", "kernelgateway", "--KernelGatewayApp.ip=0.0.0.0", "--KernelGatewayApp.port=8888"] diff --git a/deno-notebook/setup-scripts/kernel-deno.json b/deno-notebook/setup-scripts/kernel-deno.json new file mode 100644 index 0000000..ef437bb --- /dev/null +++ b/deno-notebook/setup-scripts/kernel-deno.json @@ -0,0 +1,12 @@ +{ + "argv": [ + "deno", + "--unstable-ffi", + "jupyter", + "--kernel", + "--conn", + "{connection_file}" + ], + "display_name": "Deno", + "language": "typescript" +} \ No newline at end of file diff --git a/node-notebook/Dockerfile b/node-notebook/Dockerfile new file mode 100644 index 0000000..175be2f --- /dev/null +++ b/node-notebook/Dockerfile @@ -0,0 +1,42 @@ +# Based mostly off of: +# https://github.com/jupyter/docker-stacks/blob/main/images/julia-notebook +ARG REGISTRY=quay.io +ARG OWNER=jupyter +ARG BASE_CONTAINER=$REGISTRY/$OWNER/minimal-notebook +FROM $BASE_CONTAINER + +ENV NB_UID=1000 +ENV NB_GID=100 + +# Fix: https://github.com/hadolint/hadolint/wiki/DL4006 +# Fix: https://github.com/koalaman/shellcheck/wiki/SC3014 +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +USER "${NB_USER}" + +# Install Jupyter Console and Kernel Gateway +RUN pip install jupyter-console jupyter_kernel_gateway + +# Install tslab +ENV PATH "$PATH:${CONDA_DIR}/.npm-global/bin" +RUN mkdir "${CONDA_DIR}/.npm-global" \ + && npm config set prefix "${CONDA_DIR}/.npm-global" \ + && npm install -g tslab \ + && tslab install \ + && rm -Rf "${HOME}/.npm-global/bin/tslab" + +RUN rm -Rf "${HOME}/.local/share/jupyter/kernels/tslab" \ + && mkdir -p "${CONDA_DIR}/share/jupyter/kernels/tslab" +COPY --chown=${NB_UID}:${NB_GID} "setup-scripts/kernel-tslab.json" "${CONDA_DIR}/share/jupyter/kernels/tslab/kernel.json" + +# update permissions as root +USER root +RUN fix-permissions /etc/jupyter/ \ + && fix-permissions "${CONDA_DIR}" \ + && fix-permissions "${HOME}" + +USER "${NB_USER}" + +WORKDIR "${HOME}" + +CMD ["jupyter", "kernelgateway", "--KernelGatewayApp.ip=0.0.0.0", "--KernelGatewayApp.port=8888"] diff --git a/node-notebook/setup-scripts/kernel-tslab.json b/node-notebook/setup-scripts/kernel-tslab.json new file mode 100644 index 0000000..f690f1d --- /dev/null +++ b/node-notebook/setup-scripts/kernel-tslab.json @@ -0,0 +1 @@ +{"argv": ["tslab", "kernel", "--config-path", "{connection_file}"], "display_name": "Node (TypeScript)", "language": "typescript"} \ No newline at end of file diff --git a/python-notebook/Dockerfile b/python-notebook/Dockerfile index a260481..175be2f 100644 --- a/python-notebook/Dockerfile +++ b/python-notebook/Dockerfile @@ -2,20 +2,40 @@ # https://github.com/jupyter/docker-stacks/blob/main/images/julia-notebook ARG REGISTRY=quay.io ARG OWNER=jupyter -ARG BASE_CONTAINER=$REGISTRY/$OWNER/datascience-notebook -FROM ${BASE_CONTAINER} +ARG BASE_CONTAINER=$REGISTRY/$OWNER/minimal-notebook +FROM $BASE_CONTAINER + +ENV NB_UID=1000 +ENV NB_GID=100 # Fix: https://github.com/hadolint/hadolint/wiki/DL4006 # Fix: https://github.com/koalaman/shellcheck/wiki/SC3014 SHELL ["/bin/bash", "-o", "pipefail", "-c"] -USER ${NB_UID} +USER "${NB_USER}" -# Setup IJulia kernel & other packages -COPY --chown=${NB_UID}:${NB_GID} requirements.txt "${HOME}/requirements.txt" -WORKDIR "${HOME}" -RUN pip install -r requirements.txt +# Install Jupyter Console and Kernel Gateway +RUN pip install jupyter-console jupyter_kernel_gateway + +# Install tslab +ENV PATH "$PATH:${CONDA_DIR}/.npm-global/bin" +RUN mkdir "${CONDA_DIR}/.npm-global" \ + && npm config set prefix "${CONDA_DIR}/.npm-global" \ + && npm install -g tslab \ + && tslab install \ + && rm -Rf "${HOME}/.npm-global/bin/tslab" + +RUN rm -Rf "${HOME}/.local/share/jupyter/kernels/tslab" \ + && mkdir -p "${CONDA_DIR}/share/jupyter/kernels/tslab" +COPY --chown=${NB_UID}:${NB_GID} "setup-scripts/kernel-tslab.json" "${CONDA_DIR}/share/jupyter/kernels/tslab/kernel.json" + +# update permissions as root +USER root +RUN fix-permissions /etc/jupyter/ \ + && fix-permissions "${CONDA_DIR}" \ + && fix-permissions "${HOME}" +USER "${NB_USER}" WORKDIR "${HOME}" diff --git a/python-notebook/requirements.txt b/python-notebook/requirements.txt index a051485..36d0f2e 100755 --- a/python-notebook/requirements.txt +++ b/python-notebook/requirements.txt @@ -1,3 +1,4 @@ +duckduckgo-search psycopg2-binary gpt4all jupyter_kernel_gateway