-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathone-click-deploy.sh
executable file
·103 lines (85 loc) · 3.25 KB
/
one-click-deploy.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/sh
set -e
export DEPLOYMENT_PROFILE=apspe
export DEPLOYMENT_REGION=ap-southeast-1
export DEPLOYMENT_NAMESPACE=apspe
STS=$(aws sts get-caller-identity --profile $DEPLOYMENT_PROFILE --region $DEPLOYMENT_REGION --output json)
printf "Based on your DEPLOYMENT_PROFILE and DEPLOYMENT_REGION, this is your caller identity:\n"
printf "$(echo $STS | jq)\n"
read -p "Is this correct (YyNn)? " -n 1 -r
[[ $REPLY =~ ^[Yy]$ ]] || exit 0
printf "\n"
export ACCOUNT_ID=$(echo $STS | jq .Account --raw-output)
# .npmrc in HOME
if [ -f "$HOME/.npmrc" ]; then
printf "\nDetected $HOME/.npmrc file that may interfere with the installation\n"
printf "Make sure that you have all settings properly setup (or delete it from $HOME/.npmrc)"
read -p "My .npmrc is correct (YyNn)?\n " -n 1 -r
[[ $REPLY =~ ^[Yy]$ ]] || exit 0
printf "\n"
fi
# DOCKER check
if (! docker stats --no-stream &> /dev/null); then
printf "Docker daemon is not running. Docker is mandatory to run for this deployment\n"
read -p "Start docker (YyNn)? " -n 1 -r
[[ $REPLY =~ ^[Yy]$ ]] || exit 0
printf "\n"
# Mac OS launch Docker
open /Applications/Docker.app
# Wait until Docker daemon is running and has completed initialisation
while (! docker stats --no-stream &> /dev/null); do
# Docker takes a few seconds to initialize
echo "Waiting for Docker to launch..."
sleep 5
done
fi
printf "\nMake sure you have set up the necessary configuration parameters in 'apps/infra/config'\n"
printf "Check out the README for further instructions.\n\n"
read -p "My infra config is properly setup (YyNn): " -n 1 -r
[[ $REPLY =~ ^[Yy]$ ]] || exit 0
printf "\n"
clear
printf "One-click deployment for Asset Prediction Sagemaker Pipelines Example\n"
printf "=====================================================================\n"
printf "\n"
printf "For requirements, please refer to docs/README.md\n"
printf "\n"
printf "Make sure that your NPMRC settings are correct!\n"
printf "\n"
printf "The following deployment steps will be performed:\n"
printf "\t1. Build the whole project\n"
printf "\t2. Build docker image for processing step and push it to ECR\n"
printf "\t3. CDK deploy the whole infrastructure\n"
printf "\n"
read -p "Ready (YyNn)? " -n 1 -r
[[ $REPLY =~ ^[Yy]$ ]] || exit 0
printf "\n"
#
# yarn install
yarn init-project
yarn build:all
printf "\n"
printf "\nyarn install && yarn build finished"
printf "\n"
sleep 1
pushd packages/@infra/ml-pipeline/src/pipeline-definition/docker
./build-processing-image.sh
popd
printf "\n"
printf "\nbuilding the processing docker image is finished"
printf "\n"
sleep 1
echo $(pwd)
pushd apps/infra
yarn cdk:bootstrap --profile "${DEPLOYMENT_PROFILE}" --region "${DEPLOYMENT_REGION}"
yarn dev:deploy --profile "${DEPLOYMENT_PROFILE}" --region "${DEPLOYMENT_REGION}"
popd
printf "\n"
printf "\nCDK deployment done."
printf "\n"
printf "\n"
printf "You should have received an email with your credentials to the email address you set in apps/infra/config/default-XXXXXXXXXXXX.json file.\n"
URL=$(aws cloudfront list-distributions --profile ${DEPLOYMENT_PROFILE} --output text --query 'DistributionList.Items[0].DomainName')
printf "\n"
printf "Head over to https://${URL} and use the credentials you received in the email.\n"
printf "\n"