chapter twelve

12 Packaging and deploying Streamlit apps

 

This chapter covers

  • Paid deployment options without Streamlit Community Cloud limitations
  • Packaging a Streamlit app using a Dockerfile and Docker Compose
  • Creating and configuring an AWS account for deployment
  • Deploying a Dockerized app to AWS Elastic Beanstalk
  • Adding a custom domain and HTTPS to an 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 some users

12.1.2 Deployment alternatives

12.1.3 Our approach

12.2 Packaging the app using Docker

12.2.1 Intro to Docker

12.2.2 The app in a container

12.2.3 Creating a Dockerfile

12.2.4 Excluding files from an image

12.2.5 Building an image and running a container

12.2.6 Adding a Docker Compose configuration

12.3 Deploying to AWS Elastic Beanstalk

12.3.1 An overview of AWS

12.3.2 Introducing Elastic Beanstalk

12.3.3 A mental model of the deployed app

12.3.4 Creating and preparing an AWS account

Summary