fix(docker-compose): set Keycloak's frontend/public URL
As portal can't resolve KC from JS otherwise (may receive the backend URL, which it can't find)
MODIFY
docker-compose/src/docker/.env
docker-compose/src/docker/.env
APIMAN_HOSTNAME=local.gd
APIMAN_GATEWAY_MANAGEMENT_PORT=8081
-APIMAN_GATEWAY_PORT=8080
+HTTP_PORT=8080
# If you want to set another public endpoint than the default defined in this quickstart.
-APIMAN_GATEWAY_PUBLIC_ENDPOINT=http://gateway.${APIMAN_HOSTNAME}:${APIMAN_GATEWAY_PORT}
-APIMAN_MANAGER_UI_ENDPOINT=http://apiman.${APIMAN_HOSTNAME}:${APIMAN_GATEWAY_PORT}/apimanui/api-manager/
-APIMAN_MANAGER_API_ENDPOINT=http://apiman.${APIMAN_HOSTNAME}:${APIMAN_GATEWAY_PORT}/apiman
-
-KEYCLOAK_PROTOCOL=http
-KEYCLOAK_HOST=keycloak
-KEYCLOAK_PORT=8080
-KEYCLOAK_URL=${KEYCLOAK_PROTOCOL}://${KEYCLOAK_HOST}:${KEYCLOAK_PORT}
+APIMAN_GATEWAY_PUBLIC_ENDPOINT=http://gateway.${APIMAN_HOSTNAME}:${HTTP_PORT}
+APIMAN_MANAGER_UI_ENDPOINT=http://apiman.${APIMAN_HOSTNAME}:${HTTP_PORT}/apimanui/api-manager/
+APIMAN_MANAGER_API_ENDPOINT=http://apiman.${APIMAN_HOSTNAME}:${HTTP_PORT}/apiman
+KEYCLOAK_PUBLIC_ENDPOINT=http://auth.${APIMAN_HOSTNAME}:${HTTP_PORT}
+KEYCLOAK_PRIVATE_ENDPOINT=http://keycloak:8080
+
# IMPORTANT: Run ./setup.sh *before* starting docker-compose to initialise these secret values.
KEYCLOAK_APIMAN_API_SECRET=REPLACE_THIS_SECRET
KEYCLOAK_APIMAN_UI_SECRET=REPLACE_THIS_SECRET

MODIFY
docker-compose/src/docker/data/apiman.properties
docker-compose/src/docker/data/apiman.properties
@@ -39,7 +39,7 @@ apiman.hibernate.hbm2ddl.auto=validate
apiman-manager-ui.api.authentication.type=bearerToken
apiman-manager-ui.api.authentication.token.generator=io.apiman.manager.ui.server.kc.KeyCloakBearerTokenGenerator
-# Set cross origin for the manager; *=any, comma separated names
+# Set cross-origin for the manager; *=any, comma separated names
apiman-manager-ui.allowed-cors-origins=*
# For services such as notifications we generate links so that the user can click through directly to the UI.
@@ -49,6 +49,9 @@ apiman-manager.ui.endpoint=${env:APIMAN_MANAGER_UI_ENDPOINT}
# Where is the Apiman API backend?
apiman-manager-ui.api.endpoint=${env:APIMAN_MANAGER_API_ENDPOINT}
+# You can override the default location that the portal expects Keycloak to be if it's different internally vs externally.
+apiman.auth.public.url=${env:APIMAN_AUTH_PUBLIC_URL}
+
# Security context settings.
apiman-manager.security-context.type=keycloak

MODIFY
docker-compose/src/docker/docker-compose.setup.yml
docker-compose/src/docker/docker-compose.setup.yml
@@ -4,5 +4,6 @@ services:
image: jbangdev/jbang-action
working_dir: "/ws"
command: setup.java
+ restart: "no"
volumes:
- "$PWD:/ws"

MODIFY
docker-compose/src/docker/docker-compose.yml
docker-compose/src/docker/docker-compose.yml
@@ -8,7 +8,8 @@ services:
- keycloak
environment:
# Keycloak SSO config
- - "APIMAN_AUTH_URL=${KEYCLOAK_URL}"
+ - "APIMAN_AUTH_URL=${KEYCLOAK_PRIVATE_ENDPOINT}"
+ - "APIMAN_AUTH_PUBLIC_URL=${KEYCLOAK_PUBLIC_ENDPOINT}"
- "APIMAN_AUTH_REALM=${KEYCLOAK_REALM}"
- "APIMAN_AUTH_API_SECRET=${KEYCLOAK_APIMAN_API_SECRET}"
- "APIMAN_AUTH_UI_SECRET=${KEYCLOAK_APIMAN_UI_SECRET}"
@@ -58,9 +59,6 @@ services:
apiman-gateway:
image: apiman/vertx-gateway:${project.version}
- # ports:
- # - '${APIMAN_GATEWAY_PORT}:${APIMAN_GATEWAY_PORT}'
- # - '${APIMAN_GATEWAY_MANAGEMENT_PORT}:8081'
depends_on:
elasticsearch:
condition: service_healthy
@@ -73,12 +71,11 @@ services:
-Dapiman.es.username=
-Dapiman.es.password=
-Dapiman.es.timeout=10000
- -Dapiman.auth.url=${KEYCLOAK_URL}
+ -Dapiman.auth.url=${KEYCLOAK_PRIVATE_ENDPOINT}
-Dapiman.auth.realm=${KEYCLOAK_REALM}
-Dapiman.auth.gateway.secret=${KEYCLOAK_GATEWAY_SECRET}
-DallowSelfSigned=${SELF_SIGNED}
-DallowAnyHost=${SELF_SIGNED}
- -Dapiman-manager-ui.api.endpoint=${APIMAN_MANAGER_API_ENDPOINT}
-Dapiman.public-endpoint=${APIMAN_GATEWAY_PUBLIC_ENDPOINT}
-DcachingPolicy.maxCacheSize=${MAX_CACHE_SIZE_IN_MB}
-Dapiman.gateway-allowedProtocols=${TLS_ALLOWED_PROTOCOLS:-}
@@ -206,8 +203,6 @@ services:
entrypoint: [ '/bin/bash', '-c' ]
# ./bin/kc.sh build => build and deploy custom themes, providers, etc.
# ./bin/kc.sh start-dev --import-realm => import Apiman realm, if not already imported.
- # ports:
- # - "8080:8080"
command:
- |
cd /opt/keycloak

fix(docker-compose): set Keycloak's frontend/public URL

As portal can't resolve KC from JS otherwise (may receive the backend URL, which it can't find)