Tuesday, August 7, 2018

JupyterHub + oauthenticator Setup (docker)

Clone the latest code from jupyterhub oauthenticator

git clone https://github.com/jupyterhub/oauthenticator.git
cd oauthenticator/examples/full

Create env contains all necessary environment variables to be injected into the docker container

cat > env << EOF
OAUTH_CLIENT_ID=***********************
OAUTH_CLIENT_SECRET=********************************************
OAUTH_CALLBACK_URL=http://hostname:8000/hub/oauth_callback
GITHUB_HOST=github.internal.server 
GITHUB_HTTP=true
EOF

Create users

cat > userslist << EOF
wuf admin
fwu
EOF

Build the docker container

docker build -t jupyterhub-oauth .

Rename the old container

If there is an old container with the same name, we need to rename this container and change its restart policy to avoid starting both container competing for the same ports
docker rename jupyterhub jupyterhub-backup
docker update --restart=no jupyterhub-backup
docker ps -a
docker rename  jupyterhub 

Start the container

The following line starts the docker container with 20G base storage (default is 10G), set restart policy to be always yes, we set network to use host as when running spark there is many random ports to be used
docker run -d -it --storage-opt size=20G --network host --env-file=env --restart always jupyterhub-oauth

Enter the container

docker exec -it jupyterhub bash

Set the docker container timezone

/etc# echo "America/Toronto" > /etc/timezone
/etc# rm localtime
/etc# ln -snf /usr/share/zoneinfo/America/Toronto /etc/localtime
/etc# dpkg-reconfigure -f noninteractive tzdata

No comments: