Google Cloud Platform (GCP)
First, you need to set up your Google cloud account following the Cloud Run documentation or the App Engine documentation depending on whether you would like to deploy your Panel app to Cloud Run or App Engine.
Next, you will need three files:
app.py: This is the Python file that creates the Panel App.
requirements.txt: This file lists all the package dependencies of our Panel app. Here is an example for requirements.txt:
app.yml (for App Engine) or Dockerfile (for Cloud Run)
Here is an example for app.yml (if you would like to deploy to App Engine):
Here is an example for Dockerfile (if you would like to deploy to Cloud Run):
Finally, to deploy a Panel app to App Engine run gcloud app create
and gcloud app deploy
.
Deploying with Cloud Run
To deploy a Panel app to Cloud Run, run gcloud run deploy
.
Panel apps use a websocket to the running Bokeh server. Websockets are considered by Cloud Run to be long-running HTTP requests.
If you deploy a panel app on GCP with Cloud Run, make sure you set up a long request timeout, with CLI parameter --timeout=...
The default timeout is 5 minutes, which makes the panel app lose its websocket connection after this time, leading to unresponsive UI, because Cloud Run considers the websocket as timed-out.
You can extend the timeout up to 60 minutes.
To extend the timeout duration, run gcloud run deploy --timeout 60min
.
For detailed information and steps, check out this example on how to deploy a Panel app to App Engine and this example on how to deploy a Panel app to Cloud Run.
Regarding Cloud Run, check out the documentation about Cloud run and WebSockets and about the --timeout
option