Skip to content

Commit

Permalink
feat: Continuous deployment
Browse files Browse the repository at this point in the history
Add continuous deployment for backend service on cloud run.
  • Loading branch information
Liam Stevenson authored and liam923 committed Aug 22, 2020
1 parent 9c2dc57 commit a532723
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
29 changes: 29 additions & 0 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,35 @@ steps:
dir: 'server'
waitFor: ['sandbox', 'secrets']

- name: 'gcr.io/cloud-builders/docker'
id: 'server.push.gateway'
args: ['push', 'gcr.io/${PROJECT_ID}/kript-gateway:${SHORT_SHA}']
dir: 'server'

- name: 'gcr.io/cloud-builders/docker'
id: 'server.push.grpc'
args: ['push', 'gcr.io/${PROJECT_ID}/kript-grpc:${SHORT_SHA}']
dir: 'server'

- name: 'gcr.io/cloud-builders/docker'
id: 'server.push.account'
args: ['push', 'gcr.io/${PROJECT_ID}/kript-account:${SHORT_SHA}']
dir: 'server'

- name: 'gcr.io/cloud-builders/docker'
id: 'server.push.data'
args: ['push', 'gcr.io/${PROJECT_ID}/kript-data:${SHORT_SHA}']
dir: 'server'

- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
id: 'server.deploy'
entrypoint: 'bash'
args: ['server/scripts/deploy']
env:
- 'BRANCH=$BRANCH_NAME'
- 'PROJECT_ID=$PROJECT_ID'
- 'SHORT_SHA=$SHORT_SHA'

images:
- 'gcr.io/${PROJECT_ID}/kript-gateway:${SHORT_SHA}'
- 'gcr.io/${PROJECT_ID}/kript-grpc:${SHORT_SHA}'
Expand Down
22 changes: 22 additions & 0 deletions server/scripts/deploy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e

# The purpose of this script is to deploy the docker images to Cloud Run when being built on the master branch.

if [ "$BRANCH" = "master" ]; then
echo "master branch detected. deploying commit ${SHORT_SHA} for project ${PROJECT_ID}"

echo "deploying account service: gcr.io/${PROJECT_ID}/kript-account:${SHORT_SHA}"
gcloud run deploy account --image "gcr.io/${PROJECT_ID}/kript-account:${SHORT_SHA}" --region 'us-east4' --platform managed

echo "deploying data service: gcr.io/${PROJECT_ID}/kript-data:${SHORT_SHA}"
gcloud run deploy data --image "gcr.io/${PROJECT_ID}/kript-data:${SHORT_SHA}" --region 'us-east4' --platform managed

echo "deploying gateway service: gcr.io/${PROJECT_ID}/kript-gateway:${SHORT_SHA}"
gcloud run deploy gateway --image "gcr.io/${PROJECT_ID}/kript-gateway:${SHORT_SHA}" --region 'us-east4' --platform managed

echo "deploying grpc service: gcr.io/${PROJECT_ID}/kript-grpc:${SHORT_SHA}"
gcloud run deploy grpc --image "gcr.io/${PROJECT_ID}/kript-grpc:${SHORT_SHA}" --region 'us-east4' --platform managed
else
echo "${BRANCH} branch detected; not deploying"
fi
Empty file modified server/scripts/get_secrets
100644 → 100755
Empty file.

0 comments on commit a532723

Please sign in to comment.