Skip to content

Commit a8e4f57

Browse files
committed
Bump Keycloack to 26.1, use separate postgres container and separate folder
1 parent 6f4f4f3 commit a8e4f57

File tree

1 file changed

+69
-19
lines changed

1 file changed

+69
-19
lines changed

bbb-install.sh

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ OPTIONS (install BigBlueButton):
5454
-x Use Let's Encrypt certbot with manual DNS challenges
5555
5656
-g Install Greenlight version 3
57-
-k Install Keycloak version 20
57+
-k Install Keycloak version 26
5858
5959
-t <key>:<secret> Install BigBlueButton LTI framework tools and add/update LTI consumer credentials <key>:<secret>
6060
@@ -85,7 +85,7 @@ OPTIONS (install Let's Encrypt certificate only):
8585
OPTIONS (install Greenlight only):
8686
8787
-g Install Greenlight version 3 (required)
88-
-k Install Keycloak version 20 (optional)
88+
-k Install Keycloak version 26 (optional)
8989
9090
OPTIONS (install BigBlueButton LTI framework only):
9191
@@ -124,6 +124,7 @@ main() {
124124
LETS_ENCRYPT_OPTIONS=(--webroot --non-interactive)
125125
SOURCES_FETCHED=false
126126
GL3_DIR=~/greenlight-v3
127+
KC_DIR=~/keycloack
127128
LTI_DIR=~/bbb-lti
128129
NGINX_FILES_DEST=/usr/share/bigbluebutton/nginx
129130
CR_TMPFILE=$(mktemp /tmp/carriage-return.XXXXXX)
@@ -946,33 +947,82 @@ install_greenlight_v3(){
946947
disable_nginx_site default-fe.nginx && say "found default bbb-fe 'Welcome' and disabled it!"
947948

948949
# Adding Keycloak
949-
if [ -n "$INSTALL_KC" ]; then
950-
# When attempting to install/update Keycloak let us attempt to create the database to resolve any issues caused by postgres false negatives.
951-
docker-compose -f $GL3_DIR/docker-compose.yml up -d postgres && say "started postgres"
952-
wait_postgres_start
953-
docker-compose -f $GL3_DIR/docker-compose.yml exec -T postgres psql -U postgres -c 'CREATE DATABASE keycloakdb;'
954-
fi
955950

956-
if ! grep -q 'keycloak:' $GL3_DIR/docker-compose.yml; then
951+
if [ ! -f "$KC_DIR/docker-compose.yml" ] || [ ! grep -q 'keycloak:' $GL3_DIR/docker-compose.yml ]; then
957952
# The following logic is expected to run only once when adding Keycloak.
958953
# Keycloak isn't installed
959954
if [ -n "$INSTALL_KC" ]; then
960955
# Add Keycloak
961956
say "Adding Keycloak..."
962957

963-
docker-compose -f $GL3_DIR/docker-compose.yml down
964-
cp -v $GL3_DIR/docker-compose.yml $GL3_DIR/docker-compose.base.yml # Persist working base compose file for admins as a Backup.
958+
if [ ! -d $KC_DIR ]; then
959+
mkdir -p $KC_DIR && say "created $KC_DIR"
960+
fi
961+
cat <<HERE > $KC_DIR/.env
962+
POSTGRES_DB=keycloak_db
963+
POSTGRES_USER=postgres
964+
POSTGRES_PASSWORD=
965+
KEYCLOAK_ADMIN=admin
966+
KEYCLOAK_ADMIN_PASSWORD=
967+
HERE
965968

966-
docker run --rm --entrypoint sh $GL_IMG_REPO -c 'cat docker-compose.kc.yml' >> $GL3_DIR/docker-compose.yml
969+
cat <<HERE > $KC_DIR/docker-compose.yml
970+
networks:
971+
keycloak_network:
972+
973+
services:
974+
postgres:
975+
image: postgres:17-alpine
976+
container_name: postgres-keycloack
977+
volumes:
978+
- ./postgres17:/var/lib/postgresql/data
979+
environment:
980+
POSTGRES_DB: \${POSTGRES_DB}
981+
POSTGRES_USER: \${POSTGRES_USER}
982+
POSTGRES_PASSWORD: \${POSTGRES_PASSWORD}
983+
networks:
984+
- keycloak_network
985+
986+
keycloak:
987+
image: quay.io/keycloak/keycloak:26.1
988+
container_name: keycloack
989+
command: start
990+
environment:
991+
# KC_HOSTNAME: localhost
992+
KC_HOSTNAME_PORT: 5151
993+
KC_HOSTNAME_STRICT: false
994+
KC_HTTP_ENABLED: true
995+
KC_HOSTNAME_STRICT_HTTPS: false
996+
KC_HTTP_RELATIVE_PATH: /keycloak
997+
KC_HEALTH_ENABLED: true
998+
KC_BOOTSTRAP_ADMIN_USERNAME: \${KEYCLOAK_ADMIN}
999+
KC_BOOTSTRAP_ADMIN_PASSWORD: \${KEYCLOAK_ADMIN_PASSWORD}
1000+
KC_DB: postgres
1001+
KC_DB_URL: jdbc:postgresql://postgres/\${POSTGRES_DB}
1002+
KC_DB_USERNAME: \${POSTGRES_USER}
1003+
KC_DB_PASSWORD: \${POSTGRES_PASSWORD}
1004+
KC_PROXY_HEADERS: xforwarded
1005+
1006+
ports:
1007+
- 5151:8080
1008+
restart: always
1009+
depends_on:
1010+
- postgres
1011+
networks:
1012+
- keycloak_network
1013+
1014+
volumes:
1015+
postgres17: {}
1016+
1017+
HERE
9671018

968-
if ! grep -q 'keycloak:' $GL3_DIR/docker-compose.yml; then
969-
err "failed to add Keycloak service to greenlight-v3 compose file - is docker running?"
970-
fi
971-
say "added Keycloak to compose file"
9721019

9731020
KCPASSWORD=$(openssl rand -hex 12) # Keycloak admin password.
974-
sed -i "s|^\([ \t-]*KEYCLOAK_ADMIN_PASSWORD\)\(=[ \t]*\)$|\1=$KCPASSWORD|g" $GL3_DIR/docker-compose.yml # Do not overwrite the value if not empty.
975-
sed -i "s|^\([ \t-]*KC_DB_PASSWORD\)\(=[ \t]*\)$|\1=$PGPASSWORD|g" $GL3_DIR/docker-compose.yml # Do not overwrite the value if not empty.
1021+
KCPGPASSWORD=$(openssl rand -hex 12) # Keycloak postgres password.
1022+
sed -i "s|^\([ \t-]*KEYCLOAK_ADMIN_PASSWORD\)\(=[ \t]*\)$|\1=$KCPASSWORD|g" $KC_DIR/.env # Do not overwrite the value if not empty.
1023+
sed -i "s|^\([ \t-]*POSTGRES_PASSWORD\)\(=[ \t]*\)$|\1=$KCPGPASSWORD|g" $KC_DIR/.env # Do not overwrite the value if not empty.
1024+
1025+
docker-compose -f $KC_DIR/docker-compose.yml up -d
9761026

9771027
# Updating Keycloak nginx file.
9781028
cp -v $NGINX_FILES_DEST/keycloak.nginx $NGINX_FILES_DEST/keycloak.nginx.old && say "old Keycloak nginx config can be retrieved at $NGINX_FILES_DEST/keycloak.nginx.old"
@@ -1032,7 +1082,7 @@ HERE
10321082
say "To create Greenlight administrator account, see: https://docs.bigbluebutton.org/greenlight/v3/install#creating-an-admin-account"
10331083

10341084

1035-
if grep -q 'keycloak:' $GL3_DIR/docker-compose.yml; then
1085+
if grep -q 'keycloak:' $KC_DIR/docker-compose.yml; then
10361086
say "Keycloak is installed, up to date and accessible for configuration on: https://$HOST/keycloak/"
10371087
if [ -n "$KCPASSWORD" ];then
10381088
say "Use the following credentials when accessing the admin console:"

0 commit comments

Comments
 (0)