User-defined environment variables in z2jh

In case anyone runs across this in the future, I had a similar usecase where I wanted our users to be able to set their own personal API keys for internal tools in a .bashrc file or the like. With inspiration from this answer I created a file at /usr/local/bin/start-notebook.d/source_bashrc.sh that contained:

#!/usr/bin/env bash

if [ -f "/home/jovyan/.bashrc" ]; then
  source /home/jovyan/.bashrc
fi

I added this to our custom docker image. I also had to change the command being run in the pod to start the Jupyter Notebook instance from the default of /opt/conda/bin/jupyterhub-singleuser to use /usr/local/bin/start-singleuser.sh. That will call /usr/local/bin/start.sh which will run things palced in /usr/local/bin/start-notebook.d/. I did that by making my custom images in profileList look like:

  profileList:
    - display_name: "Python 3.9"
      description: "Python 3.9 with Poetry installed"
      kubespawner_override:
        image: "customeImageName"
        cmd: "start-singleuser.sh"