-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
62 lines (46 loc) · 1.72 KB
/
Dockerfile
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
# Keycloak base image with dbildungs-iam-keycloak extensions
FROM quay.io/keycloak/keycloak:25.0.1 AS base
# Copy dbildungs-iam-keycloak specific extensions (providers, themes, etc.)
COPY src/providers/ /opt/keycloak/providers/
COPY src/themes/ /opt/keycloak/themes/
# Build Stage
FROM base AS build
# Set Keycloak settings for developer mode
ENV KC_HEALTH_ENABLED=true \
KC_METRICS_ENABLED=true \
KC_DB=dev-file \
KC_CACHE=local \
KC_FEATURES_DISABLED=impersonation,par
# Build Keycloak
RUN /opt/keycloak/bin/kc.sh build
# Development Run Stage
FROM build as development
# Set work directory
WORKDIR /opt/keycloak
# Copy necessary files
COPY --from=build /opt/keycloak/lib/quarkus/ /opt/keycloak/lib/quarkus/
# Generate auto-generated keys for HTTPS in developer mode
RUN keytool -genkeypair -storepass password -storetype PKCS12 -keyalg RSA -keysize 2048 \
-dname "CN=dbildungs-iam-server" -alias dbildungs-iam-server \
-ext "SAN:c=DNS:localhost,IP:127.0.0.1" -validity 365 -keystore conf/server.keystore
# Set entrypoint for development mode
ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "start-dev"]
# Deployment image
FROM base AS deployment-build
# Set Keycloak settings for deployment mode
ENV KC_HEALTH_ENABLED=true \
KC_METRICS_ENABLED=true \
KC_DB=postgres \
KC_FEATURES_DISABLED=impersonation,par \
KC_CACHE=ispn \
KC_CACHE_STACK=kubernetes
# Build Keycloak for deployment
RUN /opt/keycloak/bin/kc.sh build
# Deployment Run Stage
FROM deployment-build as deployment
# Set work directory
WORKDIR /opt/keycloak
# Copy necessary files
COPY --from=deployment-build /opt/keycloak/lib/quarkus/ /opt/keycloak/lib/quarkus/
# Set entrypoint for deployment mode
ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "start"]