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:
panel bokeh hvplot
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):
runtime: python env: flex entrypoint: panel serve app.py --address 0.0.0.0 --port 8080 --allow-websocket-origin="*" runtime_config: python_version: 3
Here is an example for Dockerfile (if you would like to deploy to Cloud Run):
# Use the official lightweight Python image. # https://hub.docker.com/_/python FROM python:3.10-slim # Allow statements and log messages to immediately appear in the Knative logs ENV PYTHONUNBUFFERED True # Copy local code to the container image. ENV APP_HOME /app WORKDIR $APP_HOME COPY . ./ # Install production dependencies. RUN pip install --no-cache-dir -r requirements.txt # Run the web service on container startup. CMD panel serve app.py --address 0.0.0.0 --port 8080 --allow-websocket-origin="*"
Finally, to deploy a Panel app to App Engine run
gcloud app create and
gcloud app deploy. To deploy a Panel app to Cloud Run, run
gcloud run deploy.
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.