-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild-study.sh
executable file
·50 lines (44 loc) · 1.88 KB
/
build-study.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
set -e
docker_build() {
echo "building ${GIT_SHA_IMAGE} docker image"
docker build --build-arg GIT_SHA=$GIT_SHA --build-arg ANGULAR_DIR=$ANGULAR_DIR -t ${GIT_SHA_IMAGE} . -f Dockerfile-study
echo "retagging ${GIT_SHA_IMAGE} as ${FINAL_IMAGE}"
docker tag ${GIT_SHA_IMAGE} ${FINAL_IMAGE}
}
# used only when rendering stuff for local development. not used by jenkins
render_local_config() {
local angular_study_dir="ddp-workspace/projects/${ANGULAR_DIR}"
local output_dir="${angular_study_dir}/output-config"
INPUT_DIR=config IMAGE_NAME=$FINAL_IMAGE OUTPUT_DIR=$output_dir STUDY_KEY=$STUDY_KEY STUDY_GUID=$STUDY_GUID ENVIRONMENT=$ENVIRONMENT VERSION=$VERSION MANIFEST=manifest-study.rb OUTPUT_DIR=$output_dir DIR=$output_dir ruby ./configure.rb -y
local angular_config_dir="${angular_study_dir}/src/assets/config"
}
docker_push() {
echo "pushing ${IMAGE_BASE}:${GIT_SHA}"
docker push ${IMAGE_BASE}:${GIT_SHA:0:12}
echo "pushing ${IMAGE_BASE}:$tag"
docker push ${IMAGE_BASE}:$tag
}
VERSION=$1; shift
ENVIRONMENT=$1; shift
DIR=$1; shift
STUDY_KEY=$1; shift # handy name for the study, such as angio or brain. Not the guid.
STUDY_GUID=$1; shift # guid for the study, as per pepper study configuration
ANGULAR_DIR="ddp-${STUDY_KEY}" # location of angular code
IMAGE_BASE="broadinstitute/pepper-${STUDY_KEY}" # base name fo rimage
VAULT_TOKEN=$VAULT_TOKEN
tag=${VERSION}_${ENVIRONMENT}
GIT_SHA=$(git rev-parse --verify HEAD)
GIT_SHA_IMAGE="${IMAGE_BASE}:${GIT_SHA:0:12}" # image name with git sha
FINAL_IMAGE="${IMAGE_BASE}:${tag}" # final version/env-tagged image name
while [ "$1" != "" ]; do
case $1 in
--config) render_local_config ;;
--docker-build) docker_build ;;
--docker-push) docker_build
docker_push ;;
--jenkins) docker_build
docker_push ;;
esac
shift
done