12 Packaging and deploying Streamlit apps

 

This chapter covers

  • Paid deployment options without Streamlit Community Cloud's limitations
  • Packaging a Streamlit app using a Dockerfile and Docker Compose
  • Creating and configuring your AWS account for deployment
  • Deploying your Dockerized app to AWS Elastic Beanstalk
  • Adding a custom domain and HTTPS to your app

By now, you've deployed more than one Streamlit app to the internet. You've pushed your code to GitHub and shared .streamlit.app links with the confident swagger of someone who knows their app runs in the cloud.

So far, however, the training wheels have stayed on. You haven't had to think too much about how your app handles traffic, how to port your app to a different platform, or what happens when it needs more memory. And that's been great for prototypes, demos, and quick wins.

But at some point, you'll want more. Maybe your app goes to sleep because of Streamlit Community Cloud's policy of killing apps that haven't been accessed in a while, embarrassing you in the middle of a demo. Maybe you want a proper domain so people don't think your labor of love is a half-baked side project. Or maybe you just want to have more control over the environment your app runs in.

12.1 Deployment considerations

12.1.1 Why Streamlit Community Cloud may not work for you

12.1.2 Deployment alternatives

12.1.3 Our approach

12.2 Packaging our app using Docker

12.2.1 Intro to Docker

12.2.2 Our app in a container

12.2.3 Creating a Dockerfile

12.2.4 Excluding files from your image

12.2.5 Building your image and running a container

12.2.6 Adding a Docker Compose configuration

12.3 Deploying to AWS Elastic Beanstalk

12.3.1 What is AWS?

12.3.2 What is Elastic Beanstalk?

12.3.3 A mental model of our deployed app

12.3.4 Creating and preparing your AWS account

12.3.5 Modifying your app setup for Elastic Beanstalk

12.3.6 Creating an Elastic Beanstalk app

12.4 Adding a custom domain and HTTPS

12.4.1 Adding a domain

12.4.2 Creating a certificate

12.4.3 Adding the certificate to your load balancer

12.5 Go forth and develop!

12.6 Summary