-
-
Save mightyhorst/e52b451f3083f8cfb2d76c5a2ab6d328 to your computer and use it in GitHub Desktop.
Docker deployment using Bitbucket Pipelines and Heroku
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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