-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·60 lines (46 loc) · 1.47 KB
/
run.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
#!/bin/bash
# Script to deploy the application to dev or prod.
#./eks-scale-cluster.sh --help for usage
################################### Functions ##################################
usage() {
usage="$(basename "$0") [env] [--build] - Script to deploy the application to dev or prod.
where:
- env: [dev|prod]. Choose dev to deploy locally or prod to deploy to k8s
--build: optional argument, if you want to build the image before deploying."
echo "$usage"
exit 0
}
export -f usage
##################################### Main #####################################
# If no args were supplied
if [ $# -eq 0 ]; then
echo "Error: No arguments supplied"
usage
# to print the usage text
elif [ "$1" == "--help" ];then
usage
# Start a local development environment based on docker
elif [ "$1" == "dev" ];then
echo "Deploying dev environment..."
if [ "$2" == "--build" ];then
# Build image
echo "Building image"
docker build -t nodejs-demo:latest .
fi
echo "Starting development environment"
docker stop nodejs-demo
docker rm nodejs-demo
docker run --name nodejs-demo -p 8080:8080 -d nodejs-demo
docker ps
# Deploy to k8s (prod)
elif [ "$1" == "prod" ];then
echo "Deploying prod environment..."
# if [ "$2" == "--build" ];then
# # Build image
# echo "Building image"
# docker build -t nodejs-demo:latest .
# fi
else
echo "Error: Not a valid argument"
usage
fi