Prerequisites π
- Docker π³
- cURL or something that can make a patch HTTP request
- Heroku Account
- Free time. π
Steps π¨
1. Build and play with your docker image locally
docker-compose up --build
2. Create a heroku app
- Login to heroku
- Click on this
- Enter your 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
- Login to heroku
- Go to account settings
- Scroll down click on Reveal and Get your Oauth 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
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>"