From a275873ebbdc2282db7ee4fbb874c8b8a863bd4c Mon Sep 17 00:00:00 2001 From: Carlo Minotti <50220438+minottic@users.noreply.github.com> Date: Wed, 2 Oct 2024 15:07:51 +0200 Subject: [PATCH] Add landing page service (#325) * Add landingpage service Add config Add README Add documentation to main README Add landingpage to main compose.yaml includes * Allow landingpage to use https terminated URLs Update README with HTTPS changes Use newer image and fix config * Add landingpage DEV config Add DEV instructions to landingpage README Use newer image and fix config --------- Co-authored-by: Regina Hinzmann --- README.md | 26 +++++++++-------- compose.yaml | 1 + services/landingpage/.compose.dev.yaml | 1 + services/landingpage/README.md | 23 +++++++++++++++ services/landingpage/compose.base.yaml | 17 +++++++++++ services/landingpage/compose.dev.yaml | 29 +++++++++++++++++++ services/landingpage/compose.yaml | 4 +++ services/landingpage/config/config.json | 7 +++++ .../landingpage/entrypoints/merge_json.sh | 6 ++++ services/landingpage/entrypoints/tests.sh | 5 ++++ 10 files changed, 107 insertions(+), 12 deletions(-) create mode 120000 services/landingpage/.compose.dev.yaml create mode 100644 services/landingpage/README.md create mode 100644 services/landingpage/compose.base.yaml create mode 100644 services/landingpage/compose.dev.yaml create mode 100644 services/landingpage/compose.yaml create mode 100644 services/landingpage/config/config.json create mode 100755 services/landingpage/entrypoints/merge_json.sh create mode 100755 services/landingpage/entrypoints/tests.sh diff --git a/README.md b/README.md index dec1f7d9..2e368ae2 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,8 @@ SciCat features that extend the backend are: Services that can be integrated with SciCat are: * LDAP - authentication and authorization from an LDAP server * OIDC - authentication and authorization using an OIDC provider -* SearchAPI- for better free text search in the metadata based on the PANOSC [search-api](https://github.com/SciCatProject/panosc-search-api/) +* SearchAPI - for better free text search in the metadata based on the PANOSC [search-api](https://github.com/SciCatProject/panosc-search-api/) +* LandingPage - a public interface for published datasets [landingpage](https://github.com/SciCatProject/LandingPageServer) * JupyterHub - Adds an instance of JupyterHub which demonstrates ingestion and extraction of metadata using [pyscicat](https://scicatproject.github.io/pyscicat/). To enable extra services configure them by: @@ -76,6 +77,7 @@ graph TD mongodb --> backend backend --> frontend backend --> searchapi + backend --> landingpage backend --> jupyter end @@ -135,16 +137,16 @@ For example `docker compose --profile analysis` sets up a jupyter hub with some ### Docker compose profiles and env variables configuration options -| Type | Env key | Value: Service/Feature | Default | Backend Compatibility | Description | Other impacted services | -|---------|-----------------------------|---------------------------------------------------------------------------------------|---------|-----------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------| -| profile | `COMPOSE_PROFILES` |
  • `analysis`: jupyter
  • `search`: searchapi
  • `'*'`: jupyter,searchapi
  • | `''` | * |
  • analysis: enables additional jupyter notebook with python SciCat SDK installed and example notebooks
  • search: enables a SciCat interface for standardized search | | -| env | `BE_VERSION` |
  • `v3`: backend/v3
  • `v4`: backend/v4 | `v4` | as set | Sets the BE version to use in (2) of [default setup](#default-setup) to v3 | mongodb,frontend | -| env | `JOBS_ENABLED` | `true`: rabbitmq,archivemock,jobs feature | `''` | v3 | Creates a RabbitMQ message broker which the BE posts to and the archivemock listens to. It emulates the data long-term archive/retrieve workflow | | -| env | `ELASTIC_ENABLED` | `true`: elastic,elastic feature | `''` | v4 | Creates an elastic search service and sets the BE to use it for full-text searches | | -| env | `LDAP_ENABLED` | `true`: ldap auth | `''` | * | Creates an LDAP service and sets the BE to use it as authentication backend | | -| env | `OIDC_ENABLED` | `true`: oidc auth | `''` | * | Creates an OIDC identity provider and sets the BE to use it as authentication backend | | -| env | `DEV` | `true`: backend,frontend,searchapi,archivemock in DEV mode | `''` | * | The SciCat services' environment is prepared to ease the [development in a standardized environment](#dev-configuration) | | -| env | `_HTTPS_URL` | ``: HTTPS termination | `''` | * | Requests the TLS certificate for the URL to LetsEncrypt through the [proxy](#tls-configuration) | | +| Type | Env key | Value: Service/Feature | Default | Backend Compatibility | Description | Other impacted services | +|---------|-----------------------------|---------------------------------------------------------------------------------------------------------------|---------|-----------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------| +| profile | `COMPOSE_PROFILES` |
  • `analysis`: jupyter
  • `search`: searchapi,landingpage
  • `'*'`: jupyter,searchapi,landingpage
  • | `''` | * |
  • analysis: enables additional jupyter notebook with python SciCat SDK installed and example notebooks
  • search: enables a SciCat interface for standardized search and a public interface for published datasets | | +| env | `BE_VERSION` |
  • `v3`: backend/v3
  • `v4`: backend/v4 | `v4` | as set | Sets the BE version to use in (2) of [default setup](#default-setup) to v3 | mongodb,frontend | +| env | `JOBS_ENABLED` | `true`: rabbitmq,archivemock,jobs feature | `''` | v3 | Creates a RabbitMQ message broker which the BE posts to and the archivemock listens to. It emulates the data long-term archive/retrieve workflow | | +| env | `ELASTIC_ENABLED` | `true`: elastic,elastic feature | `''` | v4 | Creates an elastic search service and sets the BE to use it for full-text searches | | +| env | `LDAP_ENABLED` | `true`: ldap auth | `''` | * | Creates an LDAP service and sets the BE to use it as authentication backend | | +| env | `OIDC_ENABLED` | `true`: oidc auth | `''` | * | Creates an OIDC identity provider and sets the BE to use it as authentication backend | | +| env | `DEV` | `true`: backend,frontend,searchapi,archivemock in DEV mode | `''` | * | The SciCat services' environment is prepared to ease the [development in a standardized environment](#dev-configuration) | | +| env | `_HTTPS_URL` | ``: HTTPS termination | `''` | * | Requests the TLS certificate for the URL to LetsEncrypt through the [proxy](#tls-configuration) | | After optionally setting any configuration option, one can still select the services to run as described [here](#select-the-services). @@ -259,4 +261,4 @@ To add a new service, with advanced configuration (see the [backend](./services/ ## General use of SciCat -To use SciCat, please refer to the [original documentation](https://scicatproject.github.io/documentation/). +To use SciCat, please refer to the [original documentation](https://scicatproject.github.io/documentation/). \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index 31ac5427..7f3293f0 100644 --- a/compose.yaml +++ b/compose.yaml @@ -5,3 +5,4 @@ include: - services/searchapi/compose.yaml - services/proxy/compose.yaml - services/jupyter/compose.yaml + - services/landingpage/compose.yaml diff --git a/services/landingpage/.compose.dev.yaml b/services/landingpage/.compose.dev.yaml new file mode 120000 index 00000000..ad51ac20 --- /dev/null +++ b/services/landingpage/.compose.dev.yaml @@ -0,0 +1 @@ +../.empty.yaml \ No newline at end of file diff --git a/services/landingpage/README.md b/services/landingpage/README.md new file mode 100644 index 00000000..8ce84be9 --- /dev/null +++ b/services/landingpage/README.md @@ -0,0 +1,23 @@ +# [Landingpage](https://github.com/SciCatProject/LandingPageServer) + +The SciCat provides standardised search on published datasets via this LandingPageServer + +## Configuration options + +The landingpage 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**. + +: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 `landingpage`. + +## Default configuration + +In the default configuration [config.json file](./config/config.json), the landingpage is set to call the `backend service` available at `backend.localhost` (either [v4](../backend/services/v4/), by default, or [v3](../backend/services/v3/) if specified otherwise by setting `BE_VERSION`) and use the `localhost` frontend to redirect to the datasets details from the published data detail page. + +For an explanation of how setting `BE_VERSION` changes the environment creation see [here](../../README.md#docker-compose-profiles-and-env-variables-configuration-options). + +## Enable additional features + +Setting the [BACKEND_HTTPS_URL and FRONTEND_HTTPS_URL env variables](../../.env) requires changing the `backend` and the `frontend` URL used by the `landingpage`. This is managed [here](./entrypoints/merge_json.sh). + +:warning: When setting `LANDINGPAGE_HTTPS_URL` it is likely you also want to set the `BACKEND_HTTPS_URL` and `FRONTEND_HTTPS_URL`, to allow the communication between the two wherever the browser is accessed. + +With `DEV=true`, please use `npm start -- --host 0.0.0.0`. This is to allow traffic from any IP to the `landingpage` component and it is necessary since the component runs in the docker network. diff --git a/services/landingpage/compose.base.yaml b/services/landingpage/compose.base.yaml new file mode 100644 index 00000000..5ac4f57f --- /dev/null +++ b/services/landingpage/compose.base.yaml @@ -0,0 +1,17 @@ +services: + landingpage: + image: ghcr.io/scicatproject/landingpageserver:v3.3 + volumes: + - ./config/config.json:/config/0.json + # docker-entrypoint.d is available only in the nginx layer + # so it is neglected in DEV + - ./entrypoints/merge_json.sh:/docker-entrypoint.d/0.sh + profiles: + - search + restart: on-failure + depends_on: + backend: + condition: service_healthy + environment: + BACKEND_URL: ${BACKEND_HTTPS_URL:-http://backend.localhost} + FRONTEND_URL: ${FRONTEND_HTTPS_URL:-http://localhost} diff --git a/services/landingpage/compose.dev.yaml b/services/landingpage/compose.dev.yaml new file mode 100644 index 00000000..76a8cb03 --- /dev/null +++ b/services/landingpage/compose.dev.yaml @@ -0,0 +1,29 @@ +services: + landingpage: + image: !reset null + build: + context: https://github.com/SciCatProject/LandingPageServer.git + target: builder + environment: + CONFIG_DIR: /home/node/app/src/assets + GITHUB_REPO: https://github.com/SciCatProject/LandingPageServer.git + CHROME_BIN: /usr/bin/chromium + volumes: + - landingpage_dev:/home/node/app + - ${PWD}/entrypoints/loop_entrypoints.sh:/usr/local/bin/loop_entrypoints.sh + - ${PWD}/entrypoints/infinite_loop.sh:/usr/local/bin/infinite_loop.sh + - ${PWD}/entrypoints/setup_git.sh:/docker-entrypoints/0.sh + - ./entrypoints/merge_json.sh:/docker-entrypoints/1.sh + - ./entrypoints/tests.sh:/docker-entrypoints/2.sh + entrypoint: loop_entrypoints.sh + command: infinite_loop.sh + labels: + - traefik.http.services.landingpage.loadbalancer.server.port=4200 + healthcheck: + test: pgrep -f "/bin/sh /usr/local/bin/infinite_loop.sh" + retries: 5 + user: root + +volumes: + landingpage_dev: + driver: local diff --git a/services/landingpage/compose.yaml b/services/landingpage/compose.yaml new file mode 100644 index 00000000..34b864fb --- /dev/null +++ b/services/landingpage/compose.yaml @@ -0,0 +1,4 @@ +include: + - path: + - compose.base.yaml + - .${DEV:+/}compose.dev.yaml diff --git a/services/landingpage/config/config.json b/services/landingpage/config/config.json new file mode 100644 index 00000000..1ed6b2ef --- /dev/null +++ b/services/landingpage/config/config.json @@ -0,0 +1,7 @@ +{ + "directMongoAccess": true, + "doiBaseUrl": "http://landingpage.localhost/detail/", + "facility": "facility", + "scicatBaseUrl": "${FRONTEND_URL}", + "lbBaseUrl": "${BACKEND_URL}" +} diff --git a/services/landingpage/entrypoints/merge_json.sh b/services/landingpage/entrypoints/merge_json.sh new file mode 100755 index 00000000..cf284a62 --- /dev/null +++ b/services/landingpage/entrypoints/merge_json.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +apk update && apk add jq gettext + +jq -s 'reduce .[] as $item ({}; . * $item)' /config/*.json | envsubst \ + > "${CONFIG_DIR:-/usr/share/nginx/html/assets}"/config.json diff --git a/services/landingpage/entrypoints/tests.sh b/services/landingpage/entrypoints/tests.sh new file mode 100755 index 00000000..f31a06c3 --- /dev/null +++ b/services/landingpage/entrypoints/tests.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +apk update && apk add chromium + +npm run test