How to host a Streamlit app on Google Cloud Run

A short guide for deploying a Streamlit app to Cloud Run on Google Cloud platform.

Google Cloud Run is a managed platform for hosting and running docker containers. So once you have a working Streamlit app, we need a way to make a docker container that runs the Streamlit app.

Pre requisites

  • Google Cloud platform account
  • Gcloud command line tool installed and authenticated
  • The code for a working Streamlit app

In your codebase create a Dockerfile with the below contents. Place this Dockerfile in the same folder as your main Streamlit python file, typically called ‘’.

  • If you have developed a Streamlit app on a different version of Python, change line 3 ‘FROM python:3.9’ to the Python version used.
  • If your Streamlit app is named something other than ‘’ change the last line accordingly.

To learn more about Docker check out the awesome repository on Github, or check out these cheatsheets to find out more about what the commands in the Dockerfile mean

Once the files are in place the below commands can be used to deploy the Streamlit app onto Cloud Run.

The first command here tells google cloud to create a docker container, and store the created docker image on Google Cloud Platform in the Container Registry.

gcloud builds submit --tag<PROJECT_NAME>/<STREAMLIT_APP_NAME> --project=<PROJECT_NAME>

The second command tells google cloud to take this newly created docker container and run it in the managed environment of Google Cloud Run.

gcloud run deploy cpp-weekly-redesign --image<PROJECT_NAME>/<STREAMLIT_APP_NAME> --platform managed  --project=<PROJECT_NAME> --allow-unauthenticated --region australia-southeast1 --memory 2Gi

There will now be URL you and anyone else can go to, to interact with your Streamlit app.

Send a Comment

Your email address will not be published.