Git Product home page Git Product logo

jupyterhub-templates's Introduction

JupyterHub Templates

The original upstream templates can be found here: https://github.com/jupyterhub/jupyterhub/tree/main/share/jupyterhub/templates

Some other examples of custom templates:

Discussion of the approach

Directory structure

The JupyterHub is being launched by the command jupyterhub and the files for this are under /usr/local/share/jupyterhub (normally). The command static_url() will take you to /usr/local/share/jupyterhub/static (normally). You can specify where jupyterhub should look for extra templates but cannot do this for the assets (images and css normally) so you need to put these where they can be found. So you mount your extra assets at /usr/local/share/jupyterhub/static/extra-assets and then you refer to them in your templates with something like href="{{ static_url('extra-assets/css/login.css') }}".

Making Changes

  1. Make your changes to the GitHub repo with your templates.
  2. Restart the pod that is running the JupyterHub (see below for instructions).
kubectl get pods -n dhub

Shows you the pods. Your hub pod with be something like hub-xxxxx.

To restart it, you can do one of these. I do the first because the 2nd frightens me.

  • make a change to config.yaml and then do a helm upgrade.
  • delete the pod with
kubectl delete pod hub-xxxx -n dhub

Debugging if your files are getting into the pod

kubectl get pods -n dhub 
# to find the hub pod name
kubectl exec --stdin --tty hub-xxxx -n dhub -- /bin/bash

Gets you into a terminal in your pod so you can look around.

Edits to your JupyterHub config file.

Add to the Z2JH config file. Uses the alpine/git image as an initContainer to clone the repo and move the template files to the right places.

  hub:
    initContainers:
      - name: git-clone-templates
        image: alpine/git
        command:
          - /bin/sh
          - -c
        args:
          - >-
              git clone --branch=master https://github.com/nmfs-opensci/jupyterhub-templates.git &&
              cp -r jupyterhub-templates/templates/* /templates &&
              cp -r jupyterhub-templates/extra-assets/* /extra-assets
        volumeMounts:
          - name: custom-templates
            mountPath: /templates
          - name: custom-templates-extra-assets
            mountPath: /extra-assets
    extraVolumes:
      - name: custom-templates
        emptyDir: {}
      - name: custom-templates-extra-assets
        emptyDir: {}
    extraVolumeMounts:
      - name: custom-templates
        mountPath: /usr/local/share/jupyterhub/custom_templates
      - name: custom-templates-static
        mountPath: /usr/local/share/jupyterhub/static/extra_assets
    extraConfig:
      templates: |
        c.JupyterHub.template_paths = ['/usr/local/share/jupyterhub/custom_templates/']

In your templates, you will refer to items from extra_assets with things like this

src="{{static_url("extra_assets/images/rstudio-logo.svg") }}"

jupyterhub-templates's People

Contributors

celine168 avatar timstewartj avatar rkevin-arch avatar sandertyu avatar eeholmes avatar moorepants avatar narrator0 avatar dvbuka avatar pmackle avatar lux12337 avatar

Watchers

Josh M. London avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.