I have Jupyterhub running on AWS EKS and using a custom image built off on jupyter-scipy notebook for my user’s environment in Kubespawner. The JupyterHub app is in a docker image thats pushed to ECR then deployed on EKS with a deploy.yaml file (i rather have used helm but my company said otherwise)
We have a total of 5 apps built with the Dash Python Library that we would like all users to have acess to. if we run these in each user’s notebook, we have to worry about the port allocations per report per user so i would like to know if there is a way we can run the web apps as a Jupyerhub Service.
Dash uses Flask as the backend. I would like to stay away from having to dockerize each app and push them to ECR if possible.
Here is an example from JupyterHub repo showing how to set up a web app based on Flask as a JupyterHub service!
1 Like
Thank you for this!
Because Jupyterhub is deployed via a dockerimage to EKS, would i be able to COPY the dash app into a directory in the dockerfile?
something like:
COPY dash_app.py /srv/jupyterhub/dash_app.py
and then in jupyterhub_config:
c.JupyterHub.services = [
{
“name”: “dash-report”,
“admin”: True, # Allow admin access to the service
“display”: True, # Display the service in the JupyterHub UI
# Internal URL where the Dash app will run
“url”: “http://127.0.0.1:8051”,
“cwd”: “/srv/jupyterhub”, # Working directory for the Dash app
# Command to run the Dash app
“command”: [“python3”, “dash_app.py”, “–port”, “8051”]
}
]
is this possible? if so, I havent been able to get it to work
Well, maybe putting all the web app related files on a persistent volume and attaching that volume to JupyterHub container is a better approach? If you dont have problem maintaing your own custom JupyterHub image, yes, your approach works as well.
What are the errors you get? You might have to add load_roles config as well to be able to access the service
2 Likes
Im not receiving any errors at all besides the 404 Not found when i go to /services//
The app is working as normal but no services are being show nor the services dropdown that should be shown when you add a service. I have no clue what the issue is.
Update - the issue was my pod wasnt updating the config file. Now everything works correctly.
For future reference & in case it helps other. I copied the file into a folder in my jupyterhub dockerfile (will probably move it to a PV).
In the jupyerhub_config:
{
“name”: “dash-report”,
“admin”: True, # Allow admin access to the service
“display”: True, # Display the service in the JupyterHub UI
# Internal URL where the Dash app will run
“url”: “http://127.0.0.1:8051”,
# Command to run the Dash app
“command”: [“python3”, “/srv/apps/dash_app.py”, “–port=8051”]
}
along with the c.JupyterHub.load_roles settings as shown in the example linked.
The app needs the use the JUPYTERHUB_SERVICE_PREFIX for requests_pathname_prefix and routes_pathname_prefix.
It also needs to run on 127.0.0.1 and a dedicated/specified port.
Thanks for the help!
1 Like