-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
init-environment.sh
executable file
·114 lines (99 loc) · 2.73 KB
/
init-environment.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
#!/usr/bin/env bash
SIMPLE_SERVICE_VERSION="1.0.0"
OPENLDAP_VERSION="1.5.0"
PHPLDAPADMIN_VERSION="0.9.0"
POSTGRES_VERSION="13.16"
KONG_VERSION="2.8.5"
if [[ "$(docker images -q ivanfranchin/simple-service:${SIMPLE_SERVICE_VERSION} 2> /dev/null)" == "" ]] ; then
echo "[WARNING] Before initialize the environment, build the simple-service Docker image: ./docker-build.sh [native]"
exit 1
fi
source scripts/my-functions.sh
echo
echo "Starting environment"
echo "===================="
echo
echo "Creating network"
echo "----------------"
docker network create springboot-kong-net
echo
echo "Starting simple-service"
echo "-----------------------"
docker run -d \
--name simple-service \
--restart=unless-stopped \
--network=springboot-kong-net \
ivanfranchin/simple-service:${SIMPLE_SERVICE_VERSION}
echo
echo "Starting openldap"
echo "-----------------"
docker run -d \
--name openldap \
-p 389:389 \
-e "LDAP_ORGANISATION=MyCompany Inc." \
-e "LDAP_DOMAIN=mycompany.com" \
--restart=unless-stopped \
--network=springboot-kong-net \
osixia/openldap:${OPENLDAP_VERSION}
echo
echo "Starting phpldapadmin"
echo "---------------------"
docker run -d \
--name phpldapadmin \
-p 6443:443 \
-e "PHPLDAPADMIN_LDAP_HOSTS=openldap" \
--restart=unless-stopped \
--network=springboot-kong-net \
osixia/phpldapadmin:${PHPLDAPADMIN_VERSION}
echo
echo "Starting kong-database"
echo "----------------------"
docker run -d \
--name kong-database \
-p 5432:5432 \
-e "POSTGRES_USER=kong" \
-e "POSTGRES_PASSWORD=kong" \
-e "POSTGRES_DB=kong" \
--restart=unless-stopped \
--network=springboot-kong-net \
postgres:${POSTGRES_VERSION}
echo
wait_for_container_log "kong-database" "port 5432"
echo
echo "Running kong-database migration"
echo "-------------------------------"
docker run --rm \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_PASSWORD=kong" \
--network=springboot-kong-net \
kong:${KONG_VERSION} kong migrations bootstrap
echo
echo "Starting kong"
echo "-------------"
docker run -d \
--name kong \
-p 8000:8000 \
-p 8443:8443 \
-p 8001:8001 \
-p 8444:8444 \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_PASSWORD=kong" \
-e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
-e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
-e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
-e "KONG_ADMIN_LISTEN=0.0.0.0:8001" \
-e "KONG_ADMIN_LISTEN_SSL=0.0.0.0:8444" \
--restart=unless-stopped \
--network=springboot-kong-net \
kong:${KONG_VERSION}
echo
wait_for_container_log "kong" "finished preloading"
echo
wait_for_container_log "simple-service" "Started"
echo
echo "Environment Up and Running"
echo "=========================="
echo