5

I would like to deploy my application as a container from Gitlab CI/CD pipeline.

A few days ago I could deploy my docker image as written in the heroku devCenter.

docker login --username=_ --password=$(heroku auth:token) registry.heroku.com

and pushed it to the heroku registry.

docker tag imageregistry.heroku.com/app/process-type

docker push registry.heroku.com/app/process-type

But then they changed the deploy in 2 steps

heroku cointainer:push

heroku container:release

Before the update it was deployed when the container was pushed into the container registry. Now I need to release it in any way.

I tried to rename the image to release and tried to install heroku CLI but then I cannot log into heroku registry.

How did you solve it?

Community
  • 1
  • 1
Julian Stier
  • 128
  • 1
  • 8

2 Answers2

8

Here's a working solution I found yesterday which trigger a release. You can keep your deployment with docker and just add this little script to your pipeline.

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

This solution comes from Kai tödter and you can find it at https://toedter.com/2018/06/02/heroku-docker-deployment-update/

Sam
  • 323
  • 2
  • 8
  • When $ ./heroku-container-release.sh i always get: /bin/sh: eval: line 77: ./heroku-container-release.sh: Permission denied. Do you know what I could try? – Julian Stier Jul 14 '18 at 16:43
  • I can't seem to get the image_id right. I Keep getting: "message": "Couldn't find that docker image.". I used my image name, "web". I'm I missing something? – daniekpo Apr 09 '19 at 04:27
3

Here's one simple way of doing it:

#.gitlab-ci.yml
..............
deploy_stage:
stage: deploy
tags:
- docker
only:
- master
script:
- docker login --username=_ --password=$HEROKU_API_KEY registry.heroku.com
- docker pull $CONTAINER_IMAGE:staging
- docker tag $CONTAINER_IMAGE:staging registry.heroku.com/django-cloud/web
- docker push registry.heroku.com/django-cloud/web
- docker run --rm -e HEROKU_API_KEY=$HEROKU_API_KEY wingrunr21/alpine-heroku-cli container:release web --app django-cloud

Ref: https://gitlab.com/Banzyme2/django-cloud9-dokcer

ENDEESA
  • 3,373
  • 2
  • 21
  • 17