Skip to content

Instantly share code, notes, and snippets.

@keidrun
Last active November 2, 2018 08:11
Show Gist options
  • Select an option

  • Save keidrun/4f25b464e81104c755f9511138262f4e to your computer and use it in GitHub Desktop.

Select an option

Save keidrun/4f25b464e81104c755f9511138262f4e to your computer and use it in GitHub Desktop.
How to adapt Heroku Container Registry's new release process, which are divided into container:push and container:release

Heroku way

  • heroku container:push web
  • heroku container:release web

The way to use an existing docker image

  • docker tag $IMAGE_ID registry.heroku.com/$HEROKU_APP/$HEROKU_PROCESS_TYPE:$TAG
  • docker push registry.heroku.com/$HEROKU_APP/$HEROKU_PROCESS_TYPE:$TAG
  • bash ./heroku-container-release.sh $HEROKU_APP $HEROKU_PROCESS_TYPE $TAG $HEROKU_API_TOKEN
#!/bin/bash
if [ $# -ne 4 ]; then
echo "The number of parameters is $#." 1>&2
echo "4 parameters required." 1>&2
echo "1 - HEROKU_APP" 1>&2
echo "2 - HEROKU_PROCESS_TYPE" 1>&2
echo "3 - TAG (release version)" 1>&2
echo "4 - HEROKU_API_TOKEN" 1>&2
exit 1
fi
readonly HEROKU_APP=$1
readonly HEROKU_PROCESS_TYPE=$2
readonly TAG=$3
readonly HEROKU_API_TOKEN=$4
imageId=$(docker inspect registry.heroku.com/$HEROKU_APP/$HEROKU_PROCESS_TYPE:$TAG --format={{.Id}})
payload='{"updates":[{"type":"web","docker_image":"'"$imageId"'"}]}'
curl -n -X PATCH https://api.heroku.com/apps/$HEROKU_APP/formation \
-d "$payload" \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.heroku+json; version=3.docker-releases" \
-H "Authorization: Bearer $HEROKU_API_TOKEN"
@giotiskl
Copy link
Copy Markdown

giotiskl commented Nov 2, 2018

Thanks for this contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment