-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-compose.yml
266 lines (258 loc) · 9.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
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
services:
simplesamlphp:
build:
context: .
entrypoint:
- '/bin/sh'
- '-c'
- |
if [ ! -f "/usr/local/share/ca-certificates/dev.crt" ]; then
if [ -f "$${CAROOT}/rootCA.pem" ]; then
cp $${CAROOT}/rootCA.pem /usr/local/share/ca-certificates/dev.crt;
update-ca-certificates;
fi
fi
# To develop comment out next line
/usr/local/bin/entrypoint /usr/local/bin/server
# To develop uncomment next line
#/bin/bash
stdin_open: true
tty: true
depends_on:
- keycloak
environment:
TZ: "Europe/Madrid"
DEBUG: "true"
APACHE2_REMOTEIP_TRUSTPROXY_HOSTNAME: "traefik.${INTERNAL_DOMAIN:-internal.test}"
SIMPLESAMLPHP_ENABLE_GLOBAL: "true"
SIMPLESAMLPHP_ENABLE_VHOST: "000-default"
SIMPLESAMLPHP_BASEURLPATH: "https://simplesamlphp.${EXTERNAL_DOMAIN:-external.test}/simplesamlphp/"
SIMPLESAMLPHP_ADMIN_PASSWORD: "password"
SIMPLESAMLPHP_DEBUG_SAML: "true"
SIMPLESAMLPHP_LOG_LEVEL: "DEBUG"
SIMPLESAMLPHP_SP_NAME: "sp-test"
SIMPLESAMLPHP_SIGN_AUTHN_REQUESTS: "true"
SIMPLESAMLPHP_SIGN_LOGOUT_REQUESTS: "true"
SIMPLESAMLPHP_SIGN_REDIRECTS_REQUESTS: "true"
SIMPLESAMLPHP_ENCRYPTED_ASSERTIONS: "true"
SIMPLESAMLPHP_SP_IDP_ID: "https://sso.${EXTERNAL_DOMAIN:-external.test}/realms/master"
SIMPLESAMLPHP_SP_IDP_METADATA_URL: "https://sso.${EXTERNAL_DOMAIN:-external.test}/realms/master/protocol/saml/descriptor"
MSMTP_HOST: "mail.${INTERNAL_DOMAIN:-internal.test}"
MSMTP_FROM: "no-reply@simplesamlphp.${EXTERNAL_DOMAIN:-external.test}"
MSMTP_PORT: 1025
# Development
SIMPLESAMLPHP_CA_FILE: "${CAROOT:-/etc/traefik/ssl/ca}/rootCA.pem"
volumes:
- /etc/localtime:/etc/localtime:ro
# Development
- "./overlay/etc/entrypoint:/etc/entrypoint"
- "./overlay/etc/server:/etc/server"
- "./overlay/usr/local/bin/entrypoint:/usr/local/bin/entrypoint"
- "./overlay/usr/local/bin/server:/usr/local/bin/server"
- "./overlay/usr/local/bin/simplesamlphp-get-sp-metadata:/usr/local/bin/simplesamlphp-get-sp-metadata"
- "./overlay/usr/local/bin/wait-for:/usr/local/bin/wait-for"
- "./overlay/usr/share/simplesamlphp/config-templates/apache2.conf:/usr/share/simplesamlphp/config-templates/apache2.conf"
- "./overlay/usr/share/simplesamlphp/config-templates/trust-forwarded-headers.php:/usr/share/simplesamlphp/config-templates/trust-forwarded-headers.php"
- "./overlay/usr/share/simplesamlphp/cli-metadata-converter.php:/usr/share/simplesamlphp/cli-metadata-converter.php"
- "./overlay/var/tmp/patches/simplesamlphp:/var/tmp/patches/simplesamlphp"
- apache2-etc:/etc/apache2
- simplesamlphp-etc:/etc/simplesamlphp
- traefik:/etc/traefik
labels:
- "traefik.enable=true"
- "traefik.http.services.simplesamlphp.loadbalancer.server.port=80"
- "traefik.http.routers.simplesamlphp.rule=Host(`simplesamlphp.${EXTERNAL_DOMAIN:-external.test}`)"
- "traefik.http.routers.simplesamlphp.entrypoints=websecure"
- "traefik.http.routers.simplesamlphp.tls=true"
traefik:
image: traefik:3.1.7
entrypoint: /etc/entrypoint/entrypoint.sh
command:
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --entrypoints.websecure.http.tls=true
- --global.checkNewVersion=false
- --global.sendAnonymousUsage=false
- --serverstransport.rootcas=$${CAROOT}/rootCA.pem
- --api.dashboard=true
- --providers.file.directory=/etc/traefik/conf/dynamic-config
- --providers.file.watch=true
- --providers.docker=true
- --providers.docker.exposedByDefault=false
- --providers.docker.watch=true
- --providers.docker.defaultRule=Host(`{{ .Name }}.${EXTERNAL_DOMAIN:-external.test}`)
- --log.level=INFO
- --log.format=json
environment:
- CAROOT=${CAROOT:-/etc/traefik/ssl/ca}
- DNS_SERVERS=${DNS_SERVERS:-8.8.8.8 8.8.4.4}
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "./traefik:/etc/entrypoint"
- traefik:/etc/traefik
- simva-dev:/simva
ports:
- "127.0.0.1:80:80"
- "127.0.0.1:443:443"
hostname: "traefik.${INTERNAL_DOMAIN:-internal.test}"
networks:
default:
aliases:
- "traefik.${EXTERNAL_DOMAIN:-external.test}"
- "sso.${EXTERNAL_DOMAIN:-external.test}"
- "simplesamlphp.${EXTERNAL_DOMAIN:-external.test}"
- "mail.${EXTERNAL_DOMAIN:-external.test}"
- "traefik.${INTERNAL_DOMAIN:-internal.test}"
labels:
- "traefik.enable=true"
# Global redirect http to https
- "traefik.http.routers.http-catchall.entrypoints=web"
- "traefik.http.routers.http-catchall.rule=HostRegexp(`{host:.+}`)"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https@file"
# Access API enpoint through traefik itself
- "traefik.http.services.api.loadbalancer.server.port=8080"
- "traefik.http.routers.dashboard.rule=Host(`traefik.${EXTERNAL_DOMAIN:-external.test}`)"
- "traefik.http.routers.dashboard.entrypoints=websecure"
- "traefik.http.routers.dashboard.tls=true"
- "traefik.http.routers.dashboard.tls.options=myTLSOptions@file"
- "traefik.http.routers.dashboard.service=api@internal"
- "traefik.http.routers.dashboard.middlewares=dashboardAuth@file"
keycloak:
image: quay.io/keycloak/keycloak:24.0.2
entrypoint:
- '/bin/bash'
- '-c'
- |
find /simva/ext -type f -iname '*.jar' -exec cp {} /opt/keycloak/providers \; ;
/opt/keycloak/bin/kc.sh build && /opt/keycloak/bin/kc.sh start --optimized --verbose
environment:
# Database
- KC_DB=mariadb
- KC_DB_URL_HOST=mariadb.${INTERNAL_DOMAIN:-internal.test}
- KC_DB_URL_DATABASE=keycloak
- KC_DB_USER=keycloak
- KC_DB_PASSWORD=password
# Master Realm + Admin user
- KC_REALM_NAME=master
- KEYCLOAK_ADMIN=admin
- KEYCLOAK_ADMIN_PASSWORD=password
# Hostname
- KC_HOSTNAME=sso.${EXTERNAL_DOMAIN:-external.test}
- KC_HOSTNAME_STRICT_HTTPS=true
- KC_HOSTNAME_STRICT=false
# HTTP
- KC_HTTP_ENABLED=true
- KC_HTTP_HOST=0.0.0.0
- HTTP_ADDRESS_FORWARDING=true
# PROXY
- KC_PROXY=edge
- KC_PROXY_HEADERS=xforwarded
- PROXY_ADDRESS_FORWARDING=true
# Log level
- KC_LOG_LEVEL=info
volumes:
- /etc/localtime:/etc/localtime:ro
- ./keycloak:/scripts/keycloak/:ro
- simva-dev:/simva
depends_on:
- mariadb
- traefik
hostname: sso.${INTERNAL_DOMAIN:-internal.test}
networks:
default:
aliases:
- sso.${INTERNAL_DOMAIN:-internal.test}
labels:
- "traefik.enable=true"
- "traefik.http.services.sso.loadbalancer.server.port=8080"
- "traefik.http.routers.sso.rule=Host(`sso.${EXTERNAL_DOMAIN:-external.test}`)"
- "traefik.http.routers.sso.entrypoints=websecure"
- "traefik.http.routers.sso.tls=true"
mariadb:
image: mariadb:10.11.9
volumes:
- /etc/localtime:/etc/localtime:ro
- keycloak-mariadb:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=keycloak
- MYSQL_USER=keycloak
- MYSQL_PASSWORD=password
hostname: mariadb.${INTERNAL_DOMAIN:-internal.test}
networks:
default:
aliases:
- mariadb.${INTERNAL_DOMAIN:-internal.test}
mail:
image: maildev/maildev:2.1.0
# Fix: https://github.com/maildev/maildev/issues/484#issuecomment-2015490293
healthcheck:
test: 'wget -O - http://127.0.0.1:$${MAILDEV_WEB_PORT}$${MAILDEV_BASE_PATHNAME}/healthz || exit 1'
hostname: mail.${INTERNAL_DOMAIN:-internal.test}
networks:
default:
aliases:
- "mail.${INTERNAL_DOMAIN:-internal.test}"
labels:
- "traefik.enable=true"
- "traefik.http.services.mail.loadbalancer.server.port=1080"
- "traefik.http.routers.mail.rule=Host(`mail.${EXTERNAL_DOMAIN:-external.test}`)"
- "traefik.http.routers.mail.entrypoints=websecure"
- "traefik.http.routers.mail.tls=true"
whoami:
image: traefik/whoami
hostname: whoami.${INTERNAL_DOMAIN:-internal.test}
networks:
default:
aliases:
- "whoami.${INTERNAL_DOMAIN:-internal.test}"
labels:
- "traefik.enable=true"
- "traefik.http.services.whoami.loadbalancer.server.port=80"
- "traefik.http.routers.whoami.rule=Host(`whoami.${EXTERNAL_DOMAIN:-external.test}`)"
- "traefik.http.routers.whoami.entrypoints=websecure"
- "traefik.http.routers.whoami.tls=true"
dns:
image: coredns/coredns:1.11.4
command: -conf /simva/coredns/Corefile
volumes:
- /etc/localtime:/etc/localtime:ro
- simva-dev:/simva
ports:
- "${DNS_BIND_IP:-127.1.1.1}:53:53/udp"
hostname: dns.${INTERNAL_DOMAIN:-internal.test}
networks:
default:
aliases:
- "dns.${INTERNAL_DOMAIN:-internal.test}"
volumes:
traefik:
driver: local
driver_opts:
type: none
o: bind
device: ./data/traefik
simva-dev:
driver: local
driver_opts:
type: none
o: bind
device: ./data/simva
keycloak-mariadb:
driver: local
driver_opts:
type: none
o: bind
device: ./data/keycloak/mariadb
apache2-etc:
driver: local
driver_opts:
type: none
o: bind
device: ./data/apache2
simplesamlphp-etc:
driver: local
driver_opts:
type: none
o: bind
device: ./data/simplesamlphp