Skip to content

Instantly share code, notes, and snippets.

@rychkog
Forked from jincod/bitbucket-pipelines.yml
Created March 28, 2020 13:51
Show Gist options
  • Select an option

  • Save rychkog/26b1773f45f7f29b35e5829629f8d975 to your computer and use it in GitHub Desktop.

Select an option

Save rychkog/26b1773f45f7f29b35e5829629f8d975 to your computer and use it in GitHub Desktop.
Docker deployment using Bitbucket Pipelines and Heroku
pipelines:
default:
- step:
name: build and publish docker image
services:
- docker
caches:
- docker
script:
- docker build -t $APP_NAME .
- docker login --username=_ --password=$HEROKU_TOKEN registry.heroku.com
- docker tag $APP_NAME registry.heroku.com/$APP_NAME/web
- docker push registry.heroku.com/$APP_NAME/web
- docker inspect registry.heroku.com/$APP_NAME/web --format={{.Id}} > WEB_DOCKER_IMAGE_ID
artifacts:
- WEB_DOCKER_IMAGE_ID
- step:
name: deploy-to-heroku
deployment: staging
script:
- export WEB_DOCKER_IMAGE_ID=$(cat WEB_DOCKER_IMAGE_ID)
- ./deploy.sh
- echo "Done..."
options:
docker: true
#!/usr/bin/env bash
set -eu
curl -n -X PATCH https://api.heroku.com/apps/$APP_NAME/formation \
-d '{
"updates": [
{
"type": "web",
"docker_image": "'"$WEB_DOCKER_IMAGE_ID"'"
}
]
}' \
-H "Content-Type: application/json" \
-H "Accept: application/vnd.heroku+json; version=3.docker-releases" \
-H "Authorization: Bearer $HEROKU_TOKEN"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment