Skip to content

Commit

Permalink
Log git commit in GAE config (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
melissachang authored Mar 27, 2019
1 parent b14f8bf commit e239519
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ dataset_config/1000_genomes/deploy.json
dataset_config/1000_genomes/private-key.json

api/app.yaml
ui/app.yaml

# For some reason these are created when deploying to GKE on Mac
*.yaml-e
Expand Down
1 change: 1 addition & 0 deletions api/app.yaml.templ
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ env_variables:
PATH_PREFIX: /api
ELASTICSEARCH_URL: http://MY_ELASTICSEARCH_URL:9200/
DATASET_CONFIG_DIR: dataset_config/MY_DATASET
GIT_COMMIT: MY_GIT_COMMIT
10 changes: 5 additions & 5 deletions deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@

### Deploy the UI Server

- Deploy:
```
gcloud config set project PROJECT_ID
cd ui && gcloud app deploy --quiet
```
- From project root run `deploy/deploy-ui.sh MY_DATASET`, where `MY_DATASET` is
the name of the config directory in `dataset_config`.
Note: App Engine deployment is
slow and can take up 10 minutes. When `deploy/deploy-ui.sh` returns, that means
deployment has completed.

### Enable Access Control

Expand Down
2 changes: 2 additions & 0 deletions deploy/deploy-api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ gcloud container clusters get-credentials elasticsearch-cluster --zone ${gke_clu

# Create api/app.yml from api/app.yml.templ
elasticsearch_url=$(kubectl get svc elasticsearch | grep elasticsearch | awk '{print $4}')
git_commit=$(git rev-parse HEAD)
sed -e "s/MY_DATASET/${dataset}/" api/app.yaml.templ > api/app.yaml
sed -i -e "s/MY_ELASTICSEARCH_URL/${elasticsearch_url}/" api/app.yaml
sed -i -e "s/MY_GIT_COMMIT/${git_commit}/" api/app.yaml

# Temporarily copy api/Dockerfile, api/app.yaml to project root.
# Unlike docker-compose, App Engine Flexible requires that docker build context
Expand Down
35 changes: 35 additions & 0 deletions deploy/deploy-ui.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
#
# Deploy UI Server on GCP.
#
# gcloud must be installed before running this script.

set -o errexit
set -o nounset

if (( $# != 1 ))
then
echo "Usage: deploy/deploy-ui.sh <dataset>"
echo " where <dataset> is the name of a directory in dataset_config/"
echo "Run this script from project root"
exit 1
fi

dataset=$1
project_id=$(jq --raw-output '.project_id' dataset_config/${dataset}/deploy.json)

bold=$(tput bold)
normal=$(tput sgr0)
echo "Deploying UI server for ${bold}dataset ${dataset}${normal} to ${bold}project ${project_id}${normal}"
echo

# Initialize gcloud command
gcloud config set project ${project_id}

# Create ui/app.yml from ui/app.yml.templ
git_commit=$(git rev-parse HEAD)
sed -e "s/MY_GIT_COMMIT/${git_commit}/" ui/app.yaml.templ > ui/app.yaml

# Deploy App Engine api service
cd ui
gcloud app deploy --quiet
2 changes: 0 additions & 2 deletions ui/app.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions ui/app.yaml.templ
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
runtime: custom
env: flex

env_variables:
GIT_COMMIT: MY_GIT_COMMIT

0 comments on commit e239519

Please sign in to comment.