JupyterHub + LDAP Auth + JupyterLab + Panel

I have a private network where a Ubuntu machine named Arkham is set up with Docker version 20.10.17, build 100c701. I am trying to setup a Docker Container of JupyterHub that will spawn JupyterLab instances upon an LDAP authentication which would allow the user to use their home in Lab. One of the things that makes this harder is that I want to be able to develop Panel notebooks and apps using Lab which is based on Bokeh and spawns preview servers as well. I have developed an environment.yml, Dockerfile and entrypoint.sh file that manages to do this just for me but even then the Panel preview server do not work properly. The goal is to make this available for any user on the network to have access to their Home in JupyterLab and allow for that instance to spawn Bokeh preview servers.

  • Dockerfile
FROM jupyterhub/jupyterhub

ENV UID=__EXAMPLE__
ENV GID=__EXAMPLE__
ENV USER=__EXAMPLE__
ENV GROUP=__EXAMPLE__

RUN apt-get update && \
    apt-get install apt-utils wget && \
    apt-get install -y \
    npm \
    nodejs \
    git \
    nano && \
    apt-get clean -y

RUN mkdir -p /opt/conda && \
    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /opt/conda/miniconda.sh && \
    bash /opt/conda/miniconda.sh -b -u -p /opt/conda

ENV PATH=$PATH:/opt/conda/condabin:/opt/conda/bin
COPY environment.yml /environment.yml
COPY requirements.txt /requirements.txt
RUN . activate
RUN conda install -y -c conda-forge mamba
RUN mamba install -y -c conda-forge --file /environment.yml
RUN python -m pip install --upgrade pip
RUN python -m pip install -r /requirements.txt
RUN conda clean -a -y
RUN addgroup --system --gid $GID $GROUP
RUN adduser --system --shell /bin/bash --uid $UID --gid $GID --disabled-password $USER
RUN echo "${USER}:1234" | chpasswd
RUN npm i configurable-http-proxy
RUN mkdir /etc/jupyterhub && cd /etc/jupyterhub
ADD jupyterhub_config.py /etc/jupyterhub/jupyterhub_config.py
# ENV BOKEH_ALLOW_WS_ORIGIN "*"
  • environment.yml
notebook
cartopy
hvplot
xarray
geoviews
netCDF4
h5netcdf
scipy
pydap
zarr
fsspec
cftime
rasterio
cfgrib
pooch
dask
bottleneck
numbagg
flox
  • jupyterhub_config.py
import pwd, subprocess

c.Authenticator.admin_users = {'__EXAMPLE__'}
c.Authenticator.allowed_users = {'__EXAMPLE__'}

def pre_spawn_hook(spawner):
    username = spawner.user.name
    try:
        pwd.getpwnam(username)
    except KeyError:
        subprocess.check_call(['useradd', '-ms', '/bin/bash', username])
c.Spawner.pre_spawn_hook = pre_spawn_hook
c.Spawner.default_url = '/lab'
  • entrypoint.sh
#!/bin/bash
. activate
jupyterhub -f /etc/jupyterhub/jupyterhub_config.py
tail -f /dev/null

This is a good guide on how to ask questions

In general it’s helpful to provide enough information for someone to reproduce your issue. For example, you could push all your deployment and configuration files to a GitHub repo or something similar.

1 Like

Thank you @manics I appreciate the feedback and have made my original question much more specific. Do I need something else?

Can you create a minimal example, perhaps one that deploys your environment on mybinder.org? This would disentangle your user and hub environment, and could give outsiders insight into the issue.

1 Like