Recently deployed a small streamlit app with AWS elastic beanstalk and docker:
Building and testing the app locally with docker and the elastic beanstalk cli was not problem. The real challenge was correctly configuring the app environment once deployed.
There are several threads floating around this corner of the forum that deal with security groups, load balancing, TCP/HTTPS, CORS, ports, sticky sessions, .toml, etc. In addition to that, there are several well written but different tutorials for cloud deployment. For a neophyte, this made it quite challenging to figure out the best approach.
So… this is what worked for me:
- Build a streamlit docker container
- Expose port 80
- Run streamlit with flags:
- In streamlit working directory init and create and elastic beanstalk environment
- After deployment success go to elastic beanstalk console in your region on AWS
- Find your environment and go to configuration → load balancer
- Under load balancer change port 80 from HTTPS to TCP and apply environment settings
- Confirm that app is running by accessing the elastic beanstalk url in the console
This approach allowed me to get past the hanging “streamlit connecting” issue after environment launch. The error appeared to be caused by the default HTTPS port listener in the load balancer.
Depending on your app design and needs your mileage may vary on this approach. There are a slew of other complexities when dealing with streamlit and cloud deployment. Trial and error was the only way I could figure it out.