Heroku Docker Deployment Update

Last Friday I gave a presentation for the Java User Group Thüringen that included a live deployment to Heroku using Docker. The deployment did not work and I found out about it one day later: Heroku has changed the workflow, Docker push to the Heroku registry does not release the app anymore. The reason for that change is explained here. In my Travis-CI builds, I added a small bash script using the Heroku API to trigger a release. Here is an example script that I use in my microservice in 60 minutes demo.

#!/bin/bash
imageId=$(docker inspect registry.heroku.com/microservice-60min/web --format={{.Id}})
payload='{"updates":[{"type":"web","docker_image":"'"$imageId"'"}]}'
curl -n -X PATCH https://api.heroku.com/apps/microservice-60min/formation \
-d "$payload" \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.heroku+json; version=3.docker-releases" \
-H "Authorization: Bearer $HEROKU_AUTH_TOKEN"

Then, the .travis.yml script part looks like:

  - docker tag kaitoedter/ms60min registry.heroku.com/microservice-60min/web
  - docker login --username=_ --password="$HEROKU_AUTH_TOKEN" registry.heroku.com
  - docker push registry.heroku.com/microservice-60min/web
  - ./heroku-container-release.sh

Now, releasing Docker images after pushing them to Heroku is working again.

Leave a Reply

I accept the Privacy Policy