fastapi / full-stack-fastapi-template

Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more.
MIT License
26.24k stars 4.59k forks source link

Auto-start Jupyter during development, and serve it at http://localhost/jup #298

Open khalo-sa opened 3 years ago

khalo-sa commented 3 years ago

Hi everyone, and thank you for this amazing project!

Since I am always using Jupyter during development, I found it a bit cumbersome to create a bash session into the backend microservice, run the $JUPYTER command, and copy paste the url+token to my browser. For this reason I have added some minor changes to the template so that Jupyter starts automatically if a RUN_JUPYTER variable is set to "true" (my default). I have also added a new traefik routing rule so that Jupyter can be reached at http://localhost/jup for convenience.

Just wanted to know if others would be interested in this code change so I can create a PR.

Koschi13 commented 3 years ago

This sounds like a great addition! I personally don't use this feature but I might have at least a look at it this way 🧐

khalo-sa commented 3 years ago

For those of you who are interested in an easy solution to autostart the Jupyter server during development, add the following line to backend/app/prestart.sh:

# autostart jupyter if JUPYTER env var is set and not empty
if [ ! -z "${JUPYTER-}" ]; then $JUPYTER & fi

Provided that you left the JUPYTER env var inside docker-compose.override.yml unchanged from the template, you can find (and click) the Jupyter URL inside the backend logs via docker-compose logs backend, e.g.:

image