-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetway-initializer.sh
87 lines (67 loc) · 2.55 KB
/
getway-initializer.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
#!/bin/sh
# Check if .env file exists and load environment variables
if [ -f .env ]; then
set -a
. ./.env
set +a
fi
# Define Kong admin URL
KONG_ADMIN_URL="http://localhost:8001"
# Wait for Kong to be ready
until curl --output /dev/null --silent --head --fail $KONG_ADMIN_URL; do
printf '.'
sleep 5
done
# Register services and add JWT plugin to each service
# Service: user-service
curl -i -X POST $KONG_ADMIN_URL/services/ \
--data "name=user-service" \
--data "url=http://host.docker.internal:8081"
curl -i -X POST $KONG_ADMIN_URL/services/user-service/routes \
--data "paths[]=/user-service" \
--data "strip_path=true"
# Service: inventory-service
curl -i -X POST $KONG_ADMIN_URL/services/ \
--data "name=inventory-service" \
--data "url=http://host.docker.internal:8082"
curl -i -X POST $KONG_ADMIN_URL/services/inventory-service/plugins \
--data "name=jwt"
curl -i -X POST $KONG_ADMIN_URL/services/inventory-service/routes \
--data "paths[]=/inventory-service" \
--data "strip_path=true"
# Service: product-service
curl -i -X POST $KONG_ADMIN_URL/services/ \
--data "name=product-service" \
--data "url=http://host.docker.internal:8083"
curl -i -X POST $KONG_ADMIN_URL/services/product-service/plugins \
--data "name=jwt"
curl -i -X POST $KONG_ADMIN_URL/services/product-service/routes \
--data "paths[]=/product-service" \
--data "strip_path=true"
# Service: order-service
curl -i -X POST $KONG_ADMIN_URL/services/ \
--data "name=order-service" \
--data "url=http://host.docker.internal:8084"
curl -i -X POST $KONG_ADMIN_URL/services/order-service/plugins \
--data "name=jwt"
curl -i -X POST $KONG_ADMIN_URL/services/order-service/routes \
--data "paths[]=/order-service" \
--data "strip_path=true"
# Service: payment-service
curl -i -X POST $KONG_ADMIN_URL/services/ \
--data "name=payment-service" \
--data "url=http://host.docker.internal:8085"
curl -i -X POST $KONG_ADMIN_URL/services/payment-service/plugins \
--data "name=jwt"
curl -i -X POST $KONG_ADMIN_URL/services/payment-service/routes \
--data "paths[]=/payment-service" \
--data "strip_path=true"
# Service: notification-service
curl -i -X POST $KONG_ADMIN_URL/services/ \
--data "name=notification-service" \
--data "url=http://host.docker.internal:8086"
curl -i -X POST $KONG_ADMIN_URL/services/notification-service/plugins \
--data "name=jwt"
curl -i -X POST $KONG_ADMIN_URL/services/notification-service/routes \
--data "paths[]=/notification-service" \
--data "strip_path=true"