From a6f457f2f3874179927180b37f3ef5fa803d1af7 Mon Sep 17 00:00:00 2001 From: christiankolbow Date: Sat, 17 Aug 2024 16:36:52 +0200 Subject: [PATCH 1/5] feat: add keycloak template --- public/svgs/keycloak.svg | 55 ++++++++++++++++++ templates/compose/keycloak-with-postgres.yaml | 58 +++++++++++++++++++ templates/compose/keycloak.yaml | 35 +++++++++++ 3 files changed, 148 insertions(+) create mode 100644 public/svgs/keycloak.svg create mode 100644 templates/compose/keycloak-with-postgres.yaml create mode 100644 templates/compose/keycloak.yaml diff --git a/public/svgs/keycloak.svg b/public/svgs/keycloak.svg new file mode 100644 index 000000000..849ac2759 --- /dev/null +++ b/public/svgs/keycloak.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/templates/compose/keycloak-with-postgres.yaml b/templates/compose/keycloak-with-postgres.yaml new file mode 100644 index 000000000..a5cdd1646 --- /dev/null +++ b/templates/compose/keycloak-with-postgres.yaml @@ -0,0 +1,58 @@ +# documentation: https://www.keycloak.org +# slogan: Keycloak is an open-source Identity and Access Management tool. +# tags: keycloak,identity,access,management,iam,authentication,authorization,security,oauth2,openid-connect,sso,single-sign-on,saml,rbac,ldap,jwt,social-login +# logo: svgs/keycloak.svg +# port: 8080 + +services: + keycloak: + image: quay.io/keycloak/keycloak:25.0.2 + command: + - start + environment: + - PUID=1000 + - PGID=1000 + - TZ=Europe/Berlin + - KEYCLOAK_ADMIN=${KEYCLOAK_ADMIN:-admin} + - KEYCLOAK_ADMIN_PASSWORD=${KEYCLOAK_ADMIN_PASSWORD:-password} + - KC_DB=postgres + - KC_DB_USERNAME=${SERVICE_USER_DATABASE} + - KC_DB_PASSWORD=${SERVICE_PASSWORD_64_DATABASE} + - KC_DB_URL_PORT=5432 + - KC_DB_URL=jdbc:postgresql://postgres/${POSTGRESQL_DATABASE:-keycloak} + - KC_HOSTNAME=${SERVICE_FQDN_KEYCLOAK_8080} + - KC_ENABLE_HTTPS=false + - KC_HTTP_ENABLED=true + - KC_HEALTH_ENABLED=true + - KC_DB_POOL_INITIAL_SIZE=${KEYCLOAK_DB_POOL_INITIAL_SIZE} + - KC_DB_POOL_MIN_SIZE=${KEYCLOAK_DB_POOL_MIN_SIZE:-0} + - KC_DB_POOL_MAX_SIZE=${KEYCLOAK_DB_POOL_MAX_SIZE:-100} + - KC_METRICS_ENABLED=${KEYCLOAK_METRICS_ENABLED:-false} + - KC_DIR=${KEYCLOAK_DIR} + - KC_FILE=${KEYCLOAK_FILE} + - KC_OVERRIDE=${KEYCLOAK_OVERRIDE:-true} + volumes: + - keycloak-data:/opt/keycloak/data + depends_on: + postgres: + condition: service_healthy + healthcheck: + 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;"] + interval: 5s + timeout: 20s + retries: 10 + postgres: + image: postgres:16-alpine + volumes: + - postgresql-data:/var/lib/postgresql/data + environment: + - POSTGRES_USER=${SERVICE_USER_DATABASE} + - POSTGRES_PASSWORD=${SERVICE_PASSWORD_64_DATABASE} + - POSTGRES_DB=${POSTGRESQL_DATABASE:-keycloak} + healthcheck: + test: + - CMD-SHELL + - pg_isready -U $${SERVICE_USER_DATABASE} -d $${POSTGRESQL_DATABASE} + interval: 5s + timeout: 20s + retries: 10 diff --git a/templates/compose/keycloak.yaml b/templates/compose/keycloak.yaml new file mode 100644 index 000000000..388d24d5b --- /dev/null +++ b/templates/compose/keycloak.yaml @@ -0,0 +1,35 @@ +# documentation: https://www.keycloak.org +# slogan: Keycloak is an open-source Identity and Access Management tool. +# tags: keycloak,identity,access,management,iam,authentication,authorization,security,oauth2,openid-connect,sso,single-sign-on,saml,rbac,ldap,jwt,social-login +# logo: svgs/keycloak.svg +# port: 8080 + +services: + keycloak: + image: quay.io/keycloak/keycloak:25.0.2 + command: + - start + environment: + - PUID=1000 + - PGID=1000 + - TZ=Europe/Berlin + - KEYCLOAK_ADMIN=${KEYCLOAK_ADMIN:-admin} + - KEYCLOAK_ADMIN_PASSWORD=${KEYCLOAK_ADMIN_PASSWORD:-password} + - KC_HOSTNAME=${SERVICE_FQDN_KEYCLOAK_8080} + - KC_ENABLE_HTTPS=false + - KC_HTTP_ENABLED=true + - KC_HEALTH_ENABLED=true + - KC_DB_POOL_INITIAL_SIZE=${KEYCLOAK_DB_POOL_INITIAL_SIZE} + - KC_DB_POOL_MIN_SIZE=${KEYCLOAK_DB_POOL_MIN_SIZE:-0} + - KC_DB_POOL_MAX_SIZE=${KEYCLOAK_DB_POOL_MAX_SIZE:-100} + - KC_METRICS_ENABLED=${KEYCLOAK_METRICS_ENABLED:-false} + - KC_DIR=${KEYCLOAK_DIR} + - KC_FILE=${KEYCLOAK_FILE} + - KC_OVERRIDE=${KEYCLOAK_OVERRIDE:-true} + volumes: + - keycloak-data:/opt/keycloak/data + healthcheck: + 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;"] + interval: 5s + timeout: 20s + retries: 10 From d53c1f99d6d49a0262e19a5ec09aa06099a7f9fa Mon Sep 17 00:00:00 2001 From: christiankolbow Date: Sat, 31 Aug 2024 08:34:10 +0200 Subject: [PATCH 2/5] fix: remove env, change timezone --- templates/compose/keycloak-with-postgres.yaml | 13 ++++++++----- templates/compose/keycloak.yaml | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/templates/compose/keycloak-with-postgres.yaml b/templates/compose/keycloak-with-postgres.yaml index a5cdd1646..2d5bb8f2b 100644 --- a/templates/compose/keycloak-with-postgres.yaml +++ b/templates/compose/keycloak-with-postgres.yaml @@ -12,16 +12,15 @@ services: environment: - PUID=1000 - PGID=1000 - - TZ=Europe/Berlin - - KEYCLOAK_ADMIN=${KEYCLOAK_ADMIN:-admin} - - KEYCLOAK_ADMIN_PASSWORD=${KEYCLOAK_ADMIN_PASSWORD:-password} + - TZ=${TIMEZONE:-UTC} + - KEYCLOAK_ADMIN=${SERVICE_USER_ADMIN} + - KEYCLOAK_ADMIN_PASSWORD=${SERVICE_PASSWORD_ADMIN} - KC_DB=postgres - KC_DB_USERNAME=${SERVICE_USER_DATABASE} - KC_DB_PASSWORD=${SERVICE_PASSWORD_64_DATABASE} - KC_DB_URL_PORT=5432 - KC_DB_URL=jdbc:postgresql://postgres/${POSTGRESQL_DATABASE:-keycloak} - KC_HOSTNAME=${SERVICE_FQDN_KEYCLOAK_8080} - - KC_ENABLE_HTTPS=false - KC_HTTP_ENABLED=true - KC_HEALTH_ENABLED=true - KC_DB_POOL_INITIAL_SIZE=${KEYCLOAK_DB_POOL_INITIAL_SIZE} @@ -37,7 +36,11 @@ services: postgres: condition: service_healthy healthcheck: - 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;"] + 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;", + ] interval: 5s timeout: 20s retries: 10 diff --git a/templates/compose/keycloak.yaml b/templates/compose/keycloak.yaml index 388d24d5b..ed141abd9 100644 --- a/templates/compose/keycloak.yaml +++ b/templates/compose/keycloak.yaml @@ -12,11 +12,10 @@ services: environment: - PUID=1000 - PGID=1000 - - TZ=Europe/Berlin - - KEYCLOAK_ADMIN=${KEYCLOAK_ADMIN:-admin} - - KEYCLOAK_ADMIN_PASSWORD=${KEYCLOAK_ADMIN_PASSWORD:-password} + - TZ=${TIMEZONE:-UTC} + - KEYCLOAK_ADMIN=${SERVICE_USER_ADMIN} + - KEYCLOAK_ADMIN_PASSWORD=${SERVICE_PASSWORD_ADMIN} - KC_HOSTNAME=${SERVICE_FQDN_KEYCLOAK_8080} - - KC_ENABLE_HTTPS=false - KC_HTTP_ENABLED=true - KC_HEALTH_ENABLED=true - KC_DB_POOL_INITIAL_SIZE=${KEYCLOAK_DB_POOL_INITIAL_SIZE} @@ -29,7 +28,11 @@ services: volumes: - keycloak-data:/opt/keycloak/data healthcheck: - 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;"] + 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;", + ] interval: 5s timeout: 20s retries: 10 From 028c41b011ec85ce865dea12b9ddd24b4b989f2f Mon Sep 17 00:00:00 2001 From: christiankolbow Date: Sat, 31 Aug 2024 09:32:28 +0200 Subject: [PATCH 3/5] fix: postgres healthcheck --- templates/compose/keycloak-with-postgres.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/compose/keycloak-with-postgres.yaml b/templates/compose/keycloak-with-postgres.yaml index 2d5bb8f2b..c1198d0ac 100644 --- a/templates/compose/keycloak-with-postgres.yaml +++ b/templates/compose/keycloak-with-postgres.yaml @@ -55,7 +55,7 @@ services: healthcheck: test: - CMD-SHELL - - pg_isready -U $${SERVICE_USER_DATABASE} -d $${POSTGRESQL_DATABASE} + - pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB} interval: 5s timeout: 20s retries: 10 From 48e4ebdb5d7fcb205a5fdb02310fb2575a449b52 Mon Sep 17 00:00:00 2001 From: christiankolbow Date: Sat, 31 Aug 2024 11:08:47 +0200 Subject: [PATCH 4/5] remove unnecessary variables --- templates/compose/keycloak-with-postgres.yaml | 9 --------- templates/compose/keycloak.yaml | 9 --------- 2 files changed, 18 deletions(-) diff --git a/templates/compose/keycloak-with-postgres.yaml b/templates/compose/keycloak-with-postgres.yaml index c1198d0ac..39f8bc731 100644 --- a/templates/compose/keycloak-with-postgres.yaml +++ b/templates/compose/keycloak-with-postgres.yaml @@ -10,8 +10,6 @@ services: command: - start environment: - - PUID=1000 - - PGID=1000 - TZ=${TIMEZONE:-UTC} - KEYCLOAK_ADMIN=${SERVICE_USER_ADMIN} - KEYCLOAK_ADMIN_PASSWORD=${SERVICE_PASSWORD_ADMIN} @@ -23,13 +21,6 @@ services: - KC_HOSTNAME=${SERVICE_FQDN_KEYCLOAK_8080} - KC_HTTP_ENABLED=true - KC_HEALTH_ENABLED=true - - KC_DB_POOL_INITIAL_SIZE=${KEYCLOAK_DB_POOL_INITIAL_SIZE} - - KC_DB_POOL_MIN_SIZE=${KEYCLOAK_DB_POOL_MIN_SIZE:-0} - - KC_DB_POOL_MAX_SIZE=${KEYCLOAK_DB_POOL_MAX_SIZE:-100} - - KC_METRICS_ENABLED=${KEYCLOAK_METRICS_ENABLED:-false} - - KC_DIR=${KEYCLOAK_DIR} - - KC_FILE=${KEYCLOAK_FILE} - - KC_OVERRIDE=${KEYCLOAK_OVERRIDE:-true} volumes: - keycloak-data:/opt/keycloak/data depends_on: diff --git a/templates/compose/keycloak.yaml b/templates/compose/keycloak.yaml index ed141abd9..fe7c0cc75 100644 --- a/templates/compose/keycloak.yaml +++ b/templates/compose/keycloak.yaml @@ -10,21 +10,12 @@ services: command: - start environment: - - PUID=1000 - - PGID=1000 - TZ=${TIMEZONE:-UTC} - KEYCLOAK_ADMIN=${SERVICE_USER_ADMIN} - KEYCLOAK_ADMIN_PASSWORD=${SERVICE_PASSWORD_ADMIN} - KC_HOSTNAME=${SERVICE_FQDN_KEYCLOAK_8080} - KC_HTTP_ENABLED=true - KC_HEALTH_ENABLED=true - - KC_DB_POOL_INITIAL_SIZE=${KEYCLOAK_DB_POOL_INITIAL_SIZE} - - KC_DB_POOL_MIN_SIZE=${KEYCLOAK_DB_POOL_MIN_SIZE:-0} - - KC_DB_POOL_MAX_SIZE=${KEYCLOAK_DB_POOL_MAX_SIZE:-100} - - KC_METRICS_ENABLED=${KEYCLOAK_METRICS_ENABLED:-false} - - KC_DIR=${KEYCLOAK_DIR} - - KC_FILE=${KEYCLOAK_FILE} - - KC_OVERRIDE=${KEYCLOAK_OVERRIDE:-true} volumes: - keycloak-data:/opt/keycloak/data healthcheck: From 82f96fe6777669e911caffca64c579cb3d66e345 Mon Sep 17 00:00:00 2001 From: christiankolbow Date: Sat, 31 Aug 2024 17:04:42 +0200 Subject: [PATCH 5/5] add proxy-headers --- templates/compose/keycloak-with-postgres.yaml | 1 + templates/compose/keycloak.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/templates/compose/keycloak-with-postgres.yaml b/templates/compose/keycloak-with-postgres.yaml index 39f8bc731..91c97c75e 100644 --- a/templates/compose/keycloak-with-postgres.yaml +++ b/templates/compose/keycloak-with-postgres.yaml @@ -21,6 +21,7 @@ services: - KC_HOSTNAME=${SERVICE_FQDN_KEYCLOAK_8080} - KC_HTTP_ENABLED=true - KC_HEALTH_ENABLED=true + - KC_PROXY_HEADERS=xforwarded volumes: - keycloak-data:/opt/keycloak/data depends_on: diff --git a/templates/compose/keycloak.yaml b/templates/compose/keycloak.yaml index fe7c0cc75..7007d1fae 100644 --- a/templates/compose/keycloak.yaml +++ b/templates/compose/keycloak.yaml @@ -16,6 +16,7 @@ services: - KC_HOSTNAME=${SERVICE_FQDN_KEYCLOAK_8080} - KC_HTTP_ENABLED=true - KC_HEALTH_ENABLED=true + - KC_PROXY_HEADERS=xforwarded volumes: - keycloak-data:/opt/keycloak/data healthcheck: