Skip to content

Commit e538318

Browse files
chore(spring-keycloak-example): add healtcheck
1 parent 6b1d7b8 commit e538318

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

spring-keycloak-example/Dockerfile.keycloak

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
FROM quay.io/keycloak/keycloak:26.3 AS builder
22

33
WORKDIR /opt/keycloak
4+
5+
ENV KC_HEALTH_ENABLED=true
6+
47
RUN /opt/keycloak/bin/kc.sh build
58

69
FROM quay.io/keycloak/keycloak:26.3

spring-keycloak-example/compose.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
services:
33

4-
#Not usable
54
app:
65
container_name: app
76
build:
@@ -19,8 +18,8 @@ services:
1918
ports:
2019
- "8083:8083"
2120
depends_on:
22-
- keycloak
23-
- keycloak-database
21+
keycloak:
22+
condition: service_healthy
2423
networks:
2524
- spring_keycloak
2625

@@ -49,10 +48,14 @@ services:
4948
- ./docker/keycloak/certs:/opt/keycloak/certs
5049
depends_on:
5150
- keycloak-database
51+
healthcheck:
52+
test: ["CMD-SHELL", "exec 3<>/dev/tcp/127.0.0.1/9000;echo -e 'GET /health/ready HTTP/1.1\r\nhost: http://localhost\r\nConnection: close\r\n\r\n' >&3;if [ $? -eq 0 ]; then echo 'Healthcheck Successful';exit 0;else echo 'Healthcheck Failed';exit 1;fi;"]
53+
interval: 5s
54+
timeout: 10s
55+
retries: 10
5256
networks:
5357
- spring_keycloak
5458

55-
5659
keycloak-database:
5760
image: postgres:14.18-alpine3.22
5861
container_name: keycloak-database

0 commit comments

Comments
 (0)