Skip to content

Commit

Permalink
feat(ui): Make the API client ID configurable
Browse files Browse the repository at this point in the history
Make the API Keycloak client ID configurable by introducing the
`UI_CLIENT_ID_SERVER` configuration variable for the UI Docker image.
Internally, this sets the `VITE_CLIENT_ID_SERVER` variable.

Setting the correct API client ID is a precondition for correctly
loading the user roles in the UI.

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher committed Oct 14, 2024
1 parent 5a7e845 commit a074c7b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
15 changes: 8 additions & 7 deletions ui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ docker run --rm -p 8082:80 ort-server-ui

The Docker image can be configured by the following environment variables:

| Variable | Default | Description |
| -------------- | ------------------------------------- | ------------------------------------ |
| `UI_API_URL` | `http://localhost:8080` | The URL of the ORT Server API. |
| `UI_URL` | `http://localhost:8082` | The URL of the UI. |
| `UI_BASEPATH` | `/` | The base path of the UI. |
| `UI_AUTHORITY` | `http://localhost:8081/realms/master` | The URL of the Keycloak realm. |
| `UI_CLIENT_ID` | `ort-server-ui` | The client ID of the UI in Keycloak. |
| Variable | Default | Description |
|-----------------------|---------------------------------------|---------------------------------------|
| `UI_API_URL` | `http://localhost:8080` | The URL of the ORT Server API. |
| `UI_URL` | `http://localhost:8082` | The URL of the UI. |
| `UI_BASEPATH` | `/` | The base path of the UI. |
| `UI_AUTHORITY` | `http://localhost:8081/realms/master` | The URL of the Keycloak realm. |
| `UI_CLIENT_ID` | `ort-server-ui` | The client ID of the UI in Keycloak. |
| `UI_CLIENT_ID_SERVER` | `ort-server` | The client ID of the API in Keycloak. |
1 change: 1 addition & 0 deletions ui/docker/UI.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ ENV VITE_API_URL="UI_API_URL_PLACEHOLDER" \
VITE_AUTHORITY="UI_AUTHORITY_PLACEHOLDER" \
VITE_BASEPATH="UI_BASEPATH_PLACEHOLDER" \
VITE_CLIENT_ID="UI_CLIENT_ID_PLACEHOLDER" \
VITE_CLIENT_ID_SERVER="UI_CLIENT_ID_SERVER_PLACEHOLDER" \
VITE_UI_URL="UI_URL_PLACEHOLDER"

RUN pnpm install --frozen-lockfile
Expand Down
2 changes: 2 additions & 0 deletions ui/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
: "${UI_AUTHORITY:=http://localhost:8081/realms/master}"
: "${UI_BASEPATH:=/}"
: "${UI_CLIENT_ID:=ort-server-ui}"
: "${UI_CLIENT_ID_SERVER:=ort-server}"
: "${UI_URL:=http://localhost:8082/}"

# Replace placeholders with actual environment variables in JavaScript files.
find /usr/share/nginx/html/assets -name '*.js' -exec sed -i "s#UI_API_URL_PLACEHOLDER#$UI_API_URL#g" {} +
find /usr/share/nginx/html/assets -name '*.js' -exec sed -i "s#UI_AUTHORITY_PLACEHOLDER#$UI_AUTHORITY#g" {} +
find /usr/share/nginx/html/assets -name '*.js' -exec sed -i "s#UI_BASEPATH_PLACEHOLDER#$UI_BASEPATH#g" {} +
find /usr/share/nginx/html/assets -name '*.js' -exec sed -i "s#UI_CLIENT_ID_PLACEHOLDER#$UI_CLIENT_ID#g" {} +
find /usr/share/nginx/html/assets -name '*.js' -exec sed -i "s#UI_CLIENT_ID_SERVER_PLACEHOLDER#$UI_CLIENT_ID_SERVER#g" {} +
find /usr/share/nginx/html/assets -name '*.js' -exec sed -i "s#UI_URL_PLACEHOLDER#$UI_URL#g" {} +

# Replace placeholders with actual environment variables in the nginx configuration.
Expand Down

0 comments on commit a074c7b

Please sign in to comment.