-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·46 lines (28 loc) · 1.23 KB
/
build.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
#!/bin/bash -ex
GCLOUD_PROJECT="${GCLOUD_PROJECT?:Variable GCLOULD_PROJECT must be set for the build}"
GCLOUD_STORAGE_BUCKET="${GCLOUD_STORAGE_BUCKET:?Variable GCLOUD_STORAGE_BUCKET must be set for the build}"
docker_build_push() {
DOCKER_IMAGE="${1:?Docker image is missing}"
docker build . -t "$DOCKER_IMAGE" --build-arg HTTP_PROXY=$http_proxy --build-arg HTTPS_PROXY=$https_proxy --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy
gcloud docker -- push "$DOCKER_IMAGE"
}
kubectl_redeploy() {
APP="${1:?Application name is required}"
DOCKER_IMAGE="${2:?Docker image name is missing}"
kubectl delete service,deployment "$APP" || true
kubectl run "$APP" --image="$DOCKER_IMAGE" --port="$PORT" $KUBECTL_RUN_PARAMS
kubectl expose deployment "$APP" $KUBECTL_EXPOSE_PARAMS
}
kubectl_info() {
APP="${1:?Application name si required}"
kubectl get service "$APP"
}
([ "$#" -gt 0 ] && echo $@ || find $(dirname $0) -name build.sh -mindepth 2) | while read MODULE; do
source "$MODULE"
DOCKER_IMAGE="us.gcr.io/$GCLOUD_PROJECT/$APP"
pushd $(dirname "$MODULE")
docker_build_push "$DOCKER_IMAGE"
kubectl_redeploy "$APP" "$DOCKER_IMAGE"
kubectl_info "$APP"
popd
done