Skip to content

Commit

Permalink
Add landing page service (#325)
Browse files Browse the repository at this point in the history
* 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 <regina.hinzmann@desy.de>
  • Loading branch information
minottic and rkweehinzmann authored Oct 2, 2024
1 parent 686d0d6 commit a275873
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 12 deletions.
26 changes: 14 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -76,6 +77,7 @@ graph TD
mongodb --> backend
backend --> frontend
backend --> searchapi
backend --> landingpage
backend --> jupyter
end
Expand Down Expand Up @@ -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` | <li>`analysis`: jupyter<li>`search`: searchapi<li>`'*'`: jupyter,searchapi</li> | `''` | * | <li>analysis: enables additional jupyter notebook with python SciCat SDK installed and example notebooks<li>search: enables a SciCat interface for standardized search | |
| env | `BE_VERSION` | <li>`v3`: backend/v3<li>`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 | `<SERVICE>_HTTPS_URL` | `<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` | <li>`analysis`: jupyter<li>`search`: searchapi,landingpage<li>`'*'`: jupyter,searchapi,landingpage</li> | `''` | * | <li>analysis: enables additional jupyter notebook with python SciCat SDK installed and example notebooks<li>search: enables a SciCat interface for standardized search and a public interface for published datasets | |
| env | `BE_VERSION` | <li>`v3`: backend/v3<li>`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 | `<SERVICE>_HTTPS_URL` | `<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).
Expand Down Expand Up @@ -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/).
1 change: 1 addition & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ include:
- services/searchapi/compose.yaml
- services/proxy/compose.yaml
- services/jupyter/compose.yaml
- services/landingpage/compose.yaml
1 change: 1 addition & 0 deletions services/landingpage/.compose.dev.yaml
23 changes: 23 additions & 0 deletions services/landingpage/README.md
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 17 additions & 0 deletions services/landingpage/compose.base.yaml
Original file line number Diff line number Diff line change
@@ -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}
29 changes: 29 additions & 0 deletions services/landingpage/compose.dev.yaml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions services/landingpage/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include:
- path:
- compose.base.yaml
- .${DEV:+/}compose.dev.yaml
7 changes: 7 additions & 0 deletions services/landingpage/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"directMongoAccess": true,
"doiBaseUrl": "http://landingpage.localhost/detail/",
"facility": "facility",
"scicatBaseUrl": "${FRONTEND_URL}",
"lbBaseUrl": "${BACKEND_URL}"
}
6 changes: 6 additions & 0 deletions services/landingpage/entrypoints/merge_json.sh
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions services/landingpage/entrypoints/tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

apk update && apk add chromium

npm run test

0 comments on commit a275873

Please sign in to comment.