Created
June 17, 2020 07:00
-
-
Save velotiotech/289df249d2f7b1f52a9486ed62bb700c to your computer and use it in GitHub Desktop.
build&pushjob.yaml job for ci/cd pipeline for k8s using circleci & helm blog
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
build&pushImage: | |
working_directory: /go/src/hello-app (1) | |
docker: | |
- image: circleci/golang:1.10 (2) | |
steps: | |
- checkout (3) | |
- run: (4) | |
name: build the binary | |
command: go build -o hello-app | |
- setup_remote_docker: (5) | |
docker_layer_caching: true | |
- run: (6) | |
name: Set the tag for the image, we will concatenate the app verson and circle build number with a `-` char in between | |
command: echo 'export TAG=$(cat VERSION)-$CIRCLE_BUILD_NUM' >> $BASH_ENV | |
- run: (7) | |
name: Build the docker image | |
command: docker build . -t ${CIRCLE_PROJECT_REPONAME}:$TAG | |
- run: (8) | |
name: Install AWS cli | |
command: export TZ=Europe/Minsk && sudo ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > sudo /etc/timezone && sudo apt-get update && sudo apt-get install -y awscli | |
- run: (9) | |
name: Login to ECR | |
command: $(aws ecr get-login --region $AWS_REGION | sed -e 's/-e none//g') | |
- run: (10) | |
name: Tag the image with ECR repo name | |
command: docker tag ${CIRCLE_PROJECT_REPONAME}:$TAG ${HELLOAPP_ECR_REPO}:$TAG | |
- run: (11) | |
name: Push the image the ECR repo | |
command: docker push ${HELLOAPP_ECR_REPO}:$TAG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment