Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compose merge approach for FE #206

Merged
merged 7 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions services/frontend/.compose.ldap.yaml
1 change: 1 addition & 0 deletions services/frontend/.compose.oidc.yaml
2 changes: 1 addition & 1 deletion services/frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The SciCat frontend is the SciCat metadata catalogue web UI, built on top of the

## Configuration options

The frontend configuration is set by the [config files](./config/). Files inside the [config](./config/) folder, with a `.json` extension are merged in alphabetical order, with [config.v3.json](./config/config.v3.json) applied depending on the [BE_VERSION](../../README.md#docker-compose-profiles-and-env-variables-configuration-options).
The frontend configuration is set by the [config files](./config/). Files inside the [config](./config/) folder, with a `.json` extension are merged respecting the alphabetical order of the files in the **container**, with [config.v3.json](./config/config.v3.json) applied depending on the [BE_VERSION](../../README.md#docker-compose-profiles-and-env-variables-configuration-options).

:warning: Please note that [merging the config files](./entrypoints/merge_json.sh) is a functionality provided by `SciCat Live` and is not supported natively by the `frontend`.

Expand Down
7 changes: 2 additions & 5 deletions services/frontend/compose.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ services:
backend:
condition: service_healthy
volumes:
- ./config:/config
- ./config/config.json:/config/0.json
- ./config/config.${BE_VERSION:-v4}.json:/config/1.json
- ${PWD}/entrypoints/loop_entrypoints.sh:/usr/local/bin/loop_entrypoints.sh
# This is numbered 1 (and not 0) as in the DEV config, which
# inherits from this, it must be run after the git_init
- ./entrypoints/merge_json.sh:/docker-entrypoints/1.sh
entrypoint: loop_entrypoints.sh
command: nginx -g "daemon off;"
environment:
BE_VERSION: ${BE_VERSION:-v4}
LDAP_ENABLED: ${LDAP_ENABLED:-}
OIDC_ENABLED: ${OIDC_ENABLED:-}
labels:
- traefik.http.routers.frontend.rule=Host(`localhost`)
4 changes: 4 additions & 0 deletions services/frontend/compose.ldap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
frontend:
volumes:
- ./config/config.ldap.json:/config/3.json
4 changes: 4 additions & 0 deletions services/frontend/compose.oidc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
services:
frontend:
volumes:
- ./config/config.oidc.json:/config/2.json
2 changes: 2 additions & 0 deletions services/frontend/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
include:
- path:
- compose.base.yaml
- .${OIDC_ENABLED:+/}compose.oidc.yaml
- .${LDAP_ENABLED:+/}compose.ldap.yaml
- .${DEV:+/}compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"accessTokenPrefix": "Bearer ",
"addDatasetEnabled":false,
"archiveWorkflowEnabled":false,
"datasetReduceEnabled":true,
"editDatasetSampleEnabled":true,
"editMetadataEnabled":true,
"editPublishedData":true,
"editSampleEnabled":true,
"externalAuthEndpoint":"/api/v3/auth/ldap",
"facility":"SAMPLE-SITE",
"fileColorEnabled":true,
"fileDownloadEnabled":true,
Expand Down
4 changes: 4 additions & 0 deletions services/frontend/config/config.v4.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"accessTokenPrefix": "Bearer ",
"externalAuthEndpoint": "/api/v3/auth/ldap"
}
14 changes: 1 addition & 13 deletions services/frontend/entrypoints/merge_json.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
#!/bin/sh
# shellcheck disable=SC2010

apk update && apk add jq

FILES=$(ls /config/*.json)

exclude_config () {
FILES=$(echo "$FILES" | xargs -n1 | grep -v "$1")
}

[ "$BE_VERSION" = "v4" ] && exclude_config "v3.json"
[ -z "$LDAP_ENABLED" ] && exclude_config "ldap.json"
[ -z "$OIDC_ENABLED" ] && exclude_config "oidc.json"

# shellcheck disable=SC2086
jq -s 'reduce .[] as $item ({}; . * $item)' $FILES > "${CONFIG_DIR:-/usr/share/nginx/html/assets}"/config.json
jq -s 'reduce .[] as $item ({}; . * $item)' /config/*.json > "${CONFIG_DIR:-/usr/share/nginx/html/assets}"/config.json