Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 76 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
version: 2
jobs:
build:
working_directory: ~/platform-wallet
environment:
PROJECT_ID: dbet-platform
docker:
- image: docker:18.06.1-ce-git
steps:
- checkout
- setup_remote_docker
- run:
name: Build application Docker image
command: |
docker build -t us.gcr.io/${PROJECT_ID}/platform-wallet:$CIRCLE_SHA1 .
- run:
name: Tag image with branch or tag
command: |
if [ -z "${CIRCLE_TAG}" ]; then
echo "Tagging image with CIRCLE_BRANCH"
docker tag "us.gcr.io/${PROJECT_ID}/platform-wallet:${CIRCLE_SHA1}" "us.gcr.io/${PROJECT_ID}/platform-wallet:${CIRCLE_BRANCH}"
else
echo "Tagging image with CIRCLE_TAG"
docker tag "us.gcr.io/${PROJECT_ID}/platform-wallet:${CIRCLE_SHA1}" "us.gcr.io/${PROJECT_ID}/platform-wallet:${CIRCLE_TAG}"
fi
- run:
name: Save Docker image layer cache
command: |
mkdir -p /caches
docker save -o /caches/app.tar us.gcr.io/${PROJECT_ID}/platform-wallet
- save_cache:
key: v2-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}-{{ .Environment.CIRCLE_TAG }}-{{ epoch }}
paths:
- /caches/app.tar
push-image-to-gcecr:
working_directory: ~/platform-wallet
docker:
- image: google/cloud-sdk
environment:
PROJECT_ID: dbet-platform
steps:
- setup_remote_docker
- restore_cache:
keys:
- v2-{{ .Branch }}-{{ .Environment.CIRCLE_SHA1 }}-{{ .Environment.CIRCLE_TAG }}
paths:
- /caches/app.tar
- run:
name: Load Docker image layer cache
command: |
set +o pipefail
docker load -i /caches/app.tar | true
- run:
name: Push image to GCE Container Registry
command: |
echo $GCLOUD_SERVICE_KEY | base64 --decode --ignore-garbage > ${HOME}/gcloud-service-key.json
export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/gcloud-service-key.json
gcloud auth activate-service-account --key-file ${HOME}/gcloud-service-key.json
gcloud config set project ${PROJECT_ID}
gcloud docker -- push us.gcr.io/${PROJECT_ID}/platform-wallet
workflows:
version: 2
build-test-deploy:
jobs:
- build:
filters:
tags:
only: /.*/
- push-image-to-gcecr:
requires:
- build
filters:
tags:
only: /.*/
branches:
ignore: /.*/
Loading