nebari icon indicating copy to clipboard operation
nebari copied to clipboard

Custom Jupyterlab Image possible?

Open joshua-alday opened this issue 5 months ago • 4 comments

Context

Hello, we want to provide our users with a robust jupyterlab experience with a full login, analytics, logging, users with separate resources, etc... Nebari looked like exactly what we needed, however we use a specific version of jupyterlab called jupyterlab-cadquery. This allows our users to render cad objects in jupyterlab. We also have custom magic functions along with our base python code that is used behind the scenes. We have everything working locally, outside of nebari.

We've noticed that nebari allows you to override the docker images. So we've looked into documentation and various repositories on nebari-dev. We did find some dockerfiles and believed we found what we need to do to roll our own image. However, there is one thing that eludes us. The dockerfiles do not include an entrypoint, which could mean that when the image is instantiated, it is given a command. What this command is we have no clue, and we can not find anything in source to indicate how this is done, nor is there any documentation hinting at this.

Value and/or benefit

If this is possible to do, it would be great to get some direction or proper documentation. Our needs require this custom jupyterlab and it feels like we are most of the way there to solving this, but there is missing information preventing us from moving quickly on this.

Anything else?

Any information would be extremely helpful.

Thank you.

joshua-alday avatar Jul 30 '25 02:07 joshua-alday

Hey @joshua-alday, sorry, I missed your issue in my box. I assume you found the image under https://github.com/nebari-dev/nebari-docker-images/blob/main/Dockerfile, which contains all of our image builds with Docker layer caching.

The best course of action for you would be to build your image using ours as the source; this way, we can guarantee maximum compatibility. Regarding the entry point of the JupyterLab image, that is handled by the Kubespawner, which jupyterhub uses under the hood, our configuration or overrides are done through this file: https://github.com/nebari-dev/nebari/blob/main/src/_nebari/stages/kubernetes_services/template/modules/kubernetes/services/jupyterhub/files/jupyterhub/03-profiles.py up user profile sections.

If you can give me more information on what you would like to have available in your entry point, I can direct you accordingly, but the gist is to drop any needs for the entry point creation.

viniciusdc avatar Aug 01 '25 00:08 viniciusdc

Heya @viniciusdc, thanks for the response. No problem on the delay, it gave me some time to dig deeper into this. I'm not a jupyterhub expert by any measure, so learning how to do things from nebari's perspective has been a bit of a drive. However, I was able to achieve what I wanted to do.

In the nebari-config.yml file that is used on nebary deploy has configurations to override jupyterhub configurations. We did end up creating a new Docker image using the nebari as a base, although we had to use a different environment to run jupyter in, but we figured out how to get everything working. But here is what we needed:

jupyterhub:
  overrides:
    singleuser:
      cmd: ["/usr/local/bin/start.sh"]
      image:
        name: xxxxxxxxx/cac_jupyterlab_cq
        tag: latest
    imagePullSecret:
      create: true
      registry: https://index.docker.io/v1/
      username: xxxxxxxxxx
      password: "{{ env.CAC_DOCKER_PAT }}"
      email: xxxxxxxxx
default_images:
  jupyterlab: "terminallabs/cac_deps_nebari_jupyterlab:latest"

I just wished it was easier to know we could do this in the nebari-config. I had to do a lot of digging to find these config options. But perhaps this is just due to my inexperience with using the whole package in general.

joshua-alday avatar Aug 01 '25 00:08 joshua-alday

Hey @joshua-alday that's excellent news! Yes, our docs are constantly shifting and I was working on this PR that will give users the ability to check all available config options in the nebari yaml file. I didn't have the chance to finish it yet.

Regarding your problem, that would be a great example to include under the overrides section of our docs. If you don't mind, could you open a PR for that? Here's where this could be included as part of the overrides for jupyterhub https://www.nebari.dev/docs/explanations/custom-overrides-configuration#jupyterhub

https://github.com/nebari-dev/nebari-docs/blob/main/docs/docs/explanations/advanced-custom-settings.md#overrides

viniciusdc avatar Aug 01 '25 16:08 viniciusdc

@viniciusdc possibly. I'll see what I can do, currently moving quickly on our deployment so I need to find the time. I don't mind this being used as an example though. However, I have another issue that I'm trying to resolve, but I will open a separate ticket for that.

joshua-alday avatar Aug 06 '25 02:08 joshua-alday