forked from HarunOr/keycloak-compose
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
151 lines (145 loc) · 4.52 KB
/
docker-compose.yml
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
---
x-logging-json:
&json-logging
driver: "json-file"
options:
max-size: "10m"
max-file: "10"
services:
postgres:
image: "postgres:${POSTGRES_VERSION}"
healthcheck:
test: ["CMD", "nc", "-zv", "localhost", "5432"]
interval: 1s
timeout: 10s
environment:
POSTGRES_DB: keycloak
POSTGRES_USER: keycloak
POSTGRES_PASSWORD: password
PGPASSWORD: password
volumes:
- ./postgres_data:/var/lib/postgresql/data
deploy:
resources:
limits:
cpus: '0.5'
memory: 525M
security_opt:
- no-new-privileges:true
networks:
- keycloak
logging: *json-logging
keycloak:
image: "quay.io/keycloak/keycloak:${KC_VERSION}"
command: ["start-dev", "--import-realm"]
restart: unless-stopped
depends_on:
- postgres
healthcheck:
test: ["CMD", "curl", "--fail", "http://localhost:8080/health/ready"]
environment:
- KC_DB=postgres
- KC_DB_USERNAME=keycloak
- KC_DB_PASSWORD=password
- KC_DB_URL=jdbc:postgresql://postgres:5432/keycloak
- KC_METRICS_ENABLED=true
- KC_HEALTH_ENABLED=true
- KC_LOG=console # can use 'gelf' https://www.keycloak.org/server/logging#_centralized_logging_using_gelf
- KC_LOG_LEVEL=${KC_LOG_LEVEL}
- KC_LOG_CONSOLE_OUTPUT=json
- KC_FEATURES=${KC_FEATURES}
- KEYCLOAK_ADMIN=${KEYCLOAK_ADMIN}
- KEYCLOAK_ADMIN_PASSWORD=${KEYCLOAK_ADMIN_PASSWORD}
- KC_REALM_NAME=${KC_REALM_NAME}
- GRAFANA_ADMIN_USERNAME=${GRAFANA_ADMIN_USERNAME}
- GRAFANA_ADMIN_PASSWORD=${GRAFANA_ADMIN_PASSWORD}
- GRAFANA_URL=${GRAFANA_HOSTNAME}:${GF_SERVER_HTTP_PORT}
ports:
- ${KC_PORT}:8080
volumes:
- ./realms/realm.json:/opt/keycloak/data/import/realm.json:ro
deploy:
resources:
limits:
cpus: '0.5'
memory: 1100M
security_opt:
- no-new-privileges:true
networks:
- keycloak
- monitoring
logging: *json-logging
prometheus:
image: "prom/prometheus:${PROMETHEUS_VERSION}"
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--storage.tsdb.retention.time=30d'
- '--storage.tsdb.wal-compression'
- '--web.enable-lifecycle'
restart: unless-stopped
depends_on:
- keycloak
healthcheck:
test: ["CMD", "wget", "--tries=1", "--spider", "http://localhost:9090"]
interval: 1s
timeout: 10s
ports:
- ${PROMETHEUS_PORT}:9090
volumes:
- prometheus_data:/prometheus
- ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
deploy:
resources:
limits:
cpus: '0.2'
memory: 525M
security_opt:
- no-new-privileges:true
networks:
- monitoring
logging: *json-logging
grafana:
image: "grafana/grafana:${GRAFANA_VERSION}"
restart: unless-stopped
network_mode: host
depends_on:
- prometheus
healthcheck:
test: ["CMD", "wget", "--tries=1", "--spider", "http://localhost:${GF_SERVER_HTTP_PORT}"]
interval: 1s
timeout: 10s
environment:
- GF_SERVER_HTTP_PORT=${GF_SERVER_HTTP_PORT}
- GF_PLUGINS_ENABLE_ALPHA=true
- GF_PLUGINS_PLUGIN_ADMIN_ENABLED=true
- GF_LOG_MODE=console
- GF_AUTH_BASIC_ENABLED=true
- GF_AUTH_GENERIC_OAUTH_TLS_SKIP_VERIFY_INSECURE=true
- GF_AUTH_DISABLE_LOGIN_FORM=true
- GF_AUTH_GENERIC_OAUTH_ENABLED=true
- GF_AUTH_GENERIC_OAUTH_NAME=Keycloak
- GF_AUTH_GENERIC_OAUTH_ALLOW_SIGN_UP=true
- GF_AUTH_GENERIC_OAUTH_CLIENT_ID=grafana
- GF_AUTH_GENERIC_OAUTH_EMAIL_ATTRIBUTE_NAME=email:primary
- GF_AUTH_GENERIC_OAUTH_SCOPES=openid profile email
- GF_AUTH_GENERIC_OAUTH_AUTH_URL=${KC_URL}/realms/${KC_REALM_NAME}/protocol/openid-connect/auth
- GF_AUTH_GENERIC_OAUTH_TOKEN_URL=${KC_URL}/realms/${KC_REALM_NAME}/protocol/openid-connect/token
- GF_AUTH_GENERIC_OAUTH_API_URL=${KC_URL}/realms/${KC_REALM_NAME}/protocol/openid-connect/userinfo
volumes:
- ./monitoring/datasources.yml:/etc/grafana/provisioning/datasources/datasources.yml:ro
- ./monitoring/dashboards.yml:/etc/grafana/provisioning/dashboards/dashboards.yml:ro
- ./monitoring/dashboards:/etc/grafana/provisioning/dashboards/keycloak:ro
deploy:
resources:
limits:
cpus: '0.3'
memory: 1100M
security_opt:
- no-new-privileges:true
logging: *json-logging
networks:
keycloak:
monitoring:
volumes:
prometheus_data: {}