-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch.sh
executable file
·54 lines (40 loc) · 1.29 KB
/
launch.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
51
52
53
54
#!/bin/sh
# Set to your docker Username
DOCKER_USERNAME=darenjacobs
# Install SDK
is_gcloud=$(which gcloud)
if ! [[ "${is_gcloud}" =~ "gcloud" ]]; then
curl -o ~/Documents/google-cloud-cli-455.0.0-darwin-x86_64.tar.gz https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-455.0.0-darwin-x86_64.tar.gz
~/Documents/google-cloud-sdk/install.sh
~/Documents/google-cloud-sdk/bin/gcloud init
fi
## # Install gke-gcloud-auth-plugin
gcloud auth application-default login
## gcloud components install gke-gcloud-auth-plugin
## gcloud config set project ${GKE_PROJECT_ID}
# Push to Docker Hub
docker login
docker build -t ${DOCKER_USERNAME}/flask-app .
docker image tag flask-app ${DOCKER_USERNAME}/flask-app:latest
docker push ${DOCKER_USERNAME}/flask-app:latest
# check for terraform
is_terraform=$(which terraform)
if ! [[ "${is_terraform}" =~ "terraform" ]]; then
echo "Terraform not found, Installing terraform"
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
fi
# Run terraform
terraform init
terraform plan -out sample.plan
terraform apply -auto-approve "sample.plan"
if [[ -f page_test.sh ]]; then
echo "RUNNING ENDPOINT TEST"
bash ./page_test.sh
fi
sleep 120
terraform destroy -auto-approve
sleep 10
rm -rf terraform.tfstate*
rm -rf .terraform
rm sample.plan