-
-
Save miguelmota/6b838fc0193af791a5fda413e2158805 to your computer and use it in GitHub Desktop.
CircleCI docker hub build and push + slack notifications
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
DOCKER_IMAGE=myorg/myimage | |
DOCKER_PASS=mydockerhubpassword | |
DOCKER_USER=mydockerhubusername | |
SLACK_ACCESS_TOKEN=myslackaccesstoken | |
SLACK_DEFAULT_CHANNEL=myslackchannel |
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
version: 2.1 | |
orbs: | |
base: dmx-io/base@2.0.88 | |
slack: circleci/slack@4.4.2 | |
jobs: | |
build: | |
working_directory: /app | |
docker: | |
- image: docker:17.05.0-ce-git | |
environment: | |
DOCKER_IMAGE=myorg/myimage | |
steps: | |
- checkout | |
- setup_remote_docker | |
- run: | |
name: Install dependencies | |
command: | | |
apk update | |
apk upgrade | |
apk add --no-cache curl | |
apk add --no-cache jq | |
apk add --no-cache py-pip=9.0.0-r1 | |
pip install \ | |
docker-compose==1.12.0 \ | |
awscli==1.11.76 | |
- run: | |
name: Build application Docker image | |
command: | | |
docker build \ | |
-f Dockerfile \ | |
--no-cache \ | |
-t app . | |
- deploy: | |
name: Push Docker image to Docker Hub | |
command: | | |
docker login -u $DOCKER_USER -p $DOCKER_PASS | |
export BRANCH=$(echo $CIRCLE_BRANCH | sed 's/\//-/g') | |
docker tag app $DOCKER_IMAGE:$CIRCLE_SHA1 | |
docker tag app $DOCKER_IMAGE:$BRANCH | |
docker push $DOCKER_IMAGE:$CIRCLE_SHA1 | |
docker push $DOCKER_IMAGE:$BRANCH | |
- slack/notify: | |
event: fail | |
template: basic_fail_1 | |
- slack/notify: | |
event: pass | |
template: basic_success_1 | |
workflows: | |
main: | |
jobs: | |
- build: | |
filters: | |
branches: | |
only: | |
- main | |
- staging | |
ignore: /.*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment