Skip to content

Dockerizing streamlit application and deploying it on heroku.

Notifications You must be signed in to change notification settings

CADLabs/streamlit-heroku

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prerequisites 📃

  1. Docker 🐳
  2. cURL or something that can make a patch HTTP request
  3. Heroku Account
  4. Free time. 😁

Steps 🔨

1. Build and play with your docker image locally

docker-compose up --build

2. Create a heroku app

  1. Login to heroku
  2. Click on this

create-new-app

  1. Enter your app name

enter-app-name

We will call the app name <APP_NAME> from this point

3. Tag your image in this format

docker tag streamlit-docker registry.heroku.com/<APP_NAME>/web

replace "streamlit-docker" to your new image name if you have changed image name in docker-compose.yml

4. Get Heroku Oauth token

  1. Login to heroku
  2. Go to account settings

login

  1. Scroll down click on Reveal and Get your Oauth token

get-token

We will call it <API_KEY> from this point

5. Get your Image Id

docker inspect --format="{{.Id}}" registry.heroku.com/<APP_NAME>/web

Psst. Its not IMAGE_NAME !

It looks something like this

sample-image-id

5. Login with your API_KEY to heroku container registry

docker login --username=_ --password=<API_KEY> registry.heroku.com

Yes the username is underscore !

6. Push the image to heroku container registry

docker push registry.heroku.com/<APP_NAME>/web

7. Trigger a deployment with cURL or requests or whatever you want.

curl --netrc -X PATCH https://api.heroku.com/apps/<APP_NAME>/formation \
  -d '{
  "updates": [
    {
      "type": "web",
      "docker_image": "<IMAGE_ID>"
    }
  ]
}' \
  -H "Content-Type: application/json" \
  -H "Accept: application/vnd.heroku+json; version=3.docker-releases"\
  -H "Authorization: Bearer <API_KEY>"

8. Go to https://<APP_NAME>.herokuapp.com and we are done with deployment. 🎉🎉

About

Dockerizing streamlit application and deploying it on heroku.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 95.5%
  • Dockerfile 4.3%
  • Shell 0.2%