forked from arulrajnet/kong-oidc-keycloak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yaml
189 lines (173 loc) · 4.15 KB
/
docker-compose.yaml
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
version: '2.4'
x-networkName: &networkName "default"
x-default: &default
dns:
- 1.1.1.1
- 1.0.0.1
x-credenv:
- &dbType postgres
- &keycloakDB keycloak
- &keycloakPass admin
- &keycloakUser admin
- &kongDB kong
- &pgHost pgsql
- &pgPass secret
- &pgPort 5432
- &pgUser postgres
x-pgenv: &pgenv
POSTGRES_USER: *pgUser
POSTGRES_PASSWORD: *pgPass
POSTGRES_DB: *keycloakDB
PGDATA: /data/postgres
x-kongmigrationenv: &kongmigrationenv
KONG_DATABASE: *dbType
KONG_PG_DATABASE: *kongDB
KONG_PG_HOST: *pgHost
KONG_PG_USER: *pgUser
KONG_PG_PASSWORD: *pgPass
networks:
*networkName:
ipam:
driver: default
services:
pgsql:
<<: *default
image: postgres:13.4-alpine
ports:
- 5432
environment:
*pgenv
volumes:
- pgdata:/data/postgres
- ./postgres-init:/docker-entrypoint-initdb.d
healthcheck:
test: ["CMD-SHELL", "pg_isready", "-U", "postgres"]
interval: 60s
timeout: 5s
retries: 3
start_period: 30s
# Kong DB bootstrap
kong-migrations:
<<: *default
build: .
image: arulrajnet/kong:dev
command: kong migrations bootstrap
depends_on:
pgsql:
condition: service_healthy
restart: on-failure
environment:
*kongmigrationenv
# Kong DB migration
kong-migrations-up:
<<: *default
build: .
image: arulrajnet/kong:dev
command: kong migrations up && kong migrations finish
depends_on:
pgsql:
condition: service_healthy
kong-migrations:
condition: service_completed_successfully
restart: on-failure
environment:
*kongmigrationenv
kong:
<<: *default
build: .
image: arulrajnet/kong:dev
depends_on:
pgsql:
condition: service_healthy
kong-migrations-up:
condition: service_completed_successfully
environment:
KONG_ADMIN_ACCESS_LOG: /dev/stdout
KONG_ADMIN_ERROR_LOG: /dev/stderr
KONG_ADMIN_LISTEN: '0.0.0.0:8001'
KONG_CASSANDRA_CONTACT_POINTS: pgsql
KONG_DATABASE: *dbType
KONG_PG_DATABASE: *kongDB
KONG_PG_HOST: *pgHost
KONG_PG_PASSWORD: *pgPass
KONG_PG_USER: *pgUser
KONG_PLUGINS: oidc
KONG_PROXY_ACCESS_LOG: /dev/stdout
KONG_PROXY_ERROR_LOG: /dev/stderr
KONG_PROXY_LISTEN: '0.0.0.0:8000'
ports:
- 8000:8000
- 8001
- 8443
- 8444
hostname: myapp.local
healthcheck:
test: ["CMD", "kong", "health"]
interval: 60s
timeout: 10s
retries: 3
start_period: 1m
restart: on-failure
keycloak:
<<: *default
image: jboss/keycloak:15.0.2
ports:
- 8080
- 9990
environment:
DB_VENDOR: *dbType
DB_SCHEMA: public
DB_ADDR: *pgHost
DB_PORT: *pgPort
DB_DATABASE: *keycloakDB
DB_USER: *pgUser
DB_PASSWORD: *pgPass
KEYCLOAK_USER: *keycloakUser
KEYCLOAK_PASSWORD: *keycloakPass
PROXY_ADDRESS_FORWARDING: "true"
depends_on:
pgsql:
condition: service_healthy
healthcheck:
test: ["CMD-SHELL", "curl --fail http://localhost:8080/auth/realms/master"]
interval: 60s
timeout: 10s
retries: 3
start_period: 1m
restart: on-failure
keycloak-config-init:
<<: *default
image: adorsys/keycloak-config-cli:v4.2.1-rc0-15.0.1
environment:
KEYCLOAK_URL: http://keycloak:8080/auth
KEYCLOAK_USER: *keycloakUser
KEYCLOAK_PASSWORD: *keycloakUser
KEYCLOAK_AVAILABILITYCHECK_ENABLED: "true"
KEYCLOAK_AVAILABILITYCHECK_TIMEOUT: 120s
IMPORT_PATH: /config
IMPORT_FORCE: "false"
depends_on:
keycloak:
condition: service_healthy
volumes:
- ./keycloak-config:/config
kong-config-init:
<<: *default
image: curlimages/curl:7.78.0
user: root
volumes:
- ./kong-config/kong-config-init.sh:/kong-config-init.sh
depends_on:
kong:
condition: service_healthy
entrypoint: /bin/sh -c "apk add --no-cache jq && /kong-config-init.sh"
restart: on-failure
httpbin:
<<: *default
image: kennethreitz/httpbin:latest
networks:
*networkName:
ports:
- 80
volumes:
pgdata: