LibreTexts / ngshare

nbgrader sharing service
https://ngshare.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
17 stars 17 forks source link

Proposed JupyterHub 3.0 Singleuser Dockerfile #159

Closed JBRhoads closed 1 year ago

JBRhoads commented 1 year ago

It appears the command to enable extensions is no longer with jupyter nbextension, but with jupyter labextension and jupyter server extension. I found this out by cross-referencing with the nbgrader docs.

Also, the z2jh 2.0.0 singleuser docker image now defaults to a non-root user, so switching to root (and back) is needed for making changes.

Proposed new sample Dockerfile:

FROM jupyterhub/k8s-singleuser-sample:2.0.0

USER root

RUN pip install nbgrader ngshare_exchange --no-cache-dir

RUN jupyter labextension enable --level=system nbgrader && \
    jupyter server extension enable --system --py nbgrader

# Configure nbgrader
COPY nbgrader_config.py /etc/jupyter/nbgrader_config.py

USER ${NB_USER}

I would've made a pull request for the dockerfile and installation documentation, but I'm not confident enough in my experience with JupyterHub to assume my understanding is adequate. Has anyone else ran into this same issue and can test?

TimStewartJ commented 1 year ago

Thanks for bringing this to our attention; You're right, there are certainly some things still out of date.

Regarding the extension commands, I am thinking about just getting rid of them. All of the extensions are enabled by default upon installation and excluding them in testing has had no affect.

In doing some digging on the Jupyter Docker images, I can't see anything that suggests usage of the k8s-singleuser-sample image as a base. I propose the following instead, based on jupyter/minimal-notebook from jupyter-docker-stacks as suggested in the z2jh docs.

FROM jupyter/minimal-notebook:hub-3.0.0

# Install ngshare_exchange
RUN python3 -m pip install ngshare_exchange --no-cache-dir

# Configure nbgrader
COPY nbgrader_config.py /etc/jupyter/nbgrader_config.py

# That's it!

Switching to root doesn't seem to be necessary since jovyan will be the only user in a singleuser container.

I'm going to make the above changes unless anyone suggests otherwise. Input would be greatly appreciated as my understanding of Jupyter related things is also limited, especially when it comes to best practices.