-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
executable file
·118 lines (103 loc) · 2.58 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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
cd "$(dirname "${BASH_SOURCE[0]}")"
#
# Prevent accidental check-ins by Curity developers
#
cp ./hooks/pre-commit .git/hooks
#
# Validate input
#
if [ "$DEPLOYMENT" != 'external' ] && [ "$DEPLOYMENT" != 'curity' ]; then
echo 'The DEPLOYMENT environment variable has not been configured correctly'
exit 1
fi
if [ "$OAUTH_PROXY_TYPE" != 'kong' ] && [ "$OAUTH_PROXY_TYPE" != 'openresty' ] && [ "$OAUTH_PROXY_TYPE" != 'nginx' ]; then
echo 'The OAUTH_PROXY_TYPE environment variable has not been configured correctly'
exit 1
fi
#
# Check that a gateway plugin ZIP file is available
#
if [ ! -f token-handler-proxy-$OAUTH_PROXY_TYPE*.zip ]; then
echo 'Please download a gateway plugin to the root folder before building'
exit 1
fi
#
# Do a release build of the SPA
#
cd spa
npm install
if [ $? -ne 0 ]; then
echo 'Problem encountered installing the SPA dependencies'
exit 1
fi
npm run build
if [ $? -ne 0 ]; then
echo 'Problem encountered building the SPA release code'
exit 1
fi
cd ..
#
# Prepare the example web host
#
cd webhost
npm install
if [ $? -ne 0 ]; then
echo 'Problem encountered installing the web host dependencies'
exit 1
fi
npm run build
if [ $? -ne 0 ]; then
echo 'Problem encountered building the web host'
exit 1
fi
cd ..
docker build -f webhost/Dockerfile -t webhost:1.0.0 .
if [ $? -ne 0 ]; then
echo 'Problem encountered building the web host Docker image'
exit 1
fi
#
# Prepare the Example API that handles JWT access tokens
#
cd api
npm install
if [ $? -ne 0 ]; then
echo 'Problem encountered installing the example API dependencies'
exit 1
fi
npm run build
if [ $? -ne 0 ]; then
echo 'Problem encountered building the example API code'
exit 1
fi
docker build -f Dockerfile -t example-api:1.0.0 .
if [ $? -ne 0 ]; then
echo 'Problem encountered building the example API Docker image'
exit 1
fi
cd ..
#
# Unpack the OAuth Proxy Plugin
#
cd "./deployments/$DEPLOYMENT/apigateway"
rm -rf resources 2>/dev/null
unzip ../../../token-handler-proxy-$OAUTH_PROXY_TYPE*.zip -d ./resources
if [ $? -ne 0 ]; then
echo 'Problem encountered unzipping the OAuth proxy files'
exit 1
fi
#
# Build a custom Docker image for the API gateway that contains plugins
#
if [ "$OAUTH_PROXY_TYPE" == 'nginx' ]; then
docker build -f nginx/Dockerfile -t apigateway-nginx:1.0.0 .
elif [ "$OAUTH_PROXY_TYPE" == 'openresty' ]; then
docker build -f openresty/Dockerfile -t apigateway-openresty:1.0.0 .
else
docker build -f kong/Dockerfile -t apigateway-kong:1.0.0 .
fi
if [ $? -ne 0 ]; then
echo "Problem encountered building the API gateway Docker image"
exit 1
fi