Skip to content

Commit

Permalink
Move fe and landingpage entrypoints to common (#326)
Browse files Browse the repository at this point in the history
* Move fe and landingpage entrypoints to common

* Rename tests to karma_tests as it is now shared
  • Loading branch information
minottic authored Oct 15, 2024
1 parent 590c83c commit dc327d5
Show file tree
Hide file tree
Showing 11 changed files with 11 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ After any configuration change, `docker compose up -d` must be rerun, to allow l

### Entrypoints

Sometimes, it is useful to run init scripts (entrypoints) before the service starts. For example, for the `frontend` composability, it is useful to specify its configuration through multiple JSON files, with different scopes, which are then merged by a [init script](./services/frontend/entrypoints/merge_json.sh). For this reason, one can define service-specific `entrypoints` (e.g. [frontend ones](./services/frontend/entrypoints/)) which can be run inside the container, before the service starts (i.e. before the docker compose `command` is executed). Whenever these entrypoints are shared between services, it is recommended to place them in an `entrypoints` folder below the outermost service (e.g. [this one](./entrypoints/)).
Sometimes, it is useful to run init scripts (entrypoints) before the service starts. For example, for the `frontend` composability, it is useful to specify its configuration through multiple JSON files, with different scopes, which are then merged by a [init script](./entrypoints/merge_json.sh). For this reason, one can define [common entrypoints](./entrypoints/) and service-specific ones (e.g. [backend v4 ones](./services/backend/services/v4/entrypoints/)) which can be run inside the container, before the service starts (i.e. before the docker compose `command` is executed). Whenever these entrypoints are shared between services, it is recommended to place them in an `entrypoints` folder below the outermost service (e.g. [this one](./entrypoints/)).

To ease the iterative execution of multiple init scripts, one can leverage the [loop_entrypoints](./entrypoints/loop_entrypoints.sh) utility, which loops alphabetically over `/docker-entrypoinst/*.sh` and executes each. This is in use in some services (e.g. in the [frontend](./services/frontend/compose.yaml)), so one can add additional init steps by mounting them, one by one, as volumes inside the container in the `/docker-entrypoints` folder and naming them depending on the desired order (eventually rename the existing ones as well).

Expand Down Expand Up @@ -255,7 +255,7 @@ To add a new service, with advanced configuration (see the [backend](./services/
5. if the service is another version of an existing one, e.g. v3 and v4 versions of the `backend` service, add the selective include in the parent compose.yaml, e.g. [here](./services/backend/compose.yaml)
6. eventually, modify the [compose workflow](.github/workflows/compose_test.yaml) to add the toggle to the matrix. If the toggle depends on the changed files, remember to create the toggle configuration [here](.github/changed_files.yaml) and create the [exclude](https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs#excluding-matrix-configurations) rule in the workflow.

4. eventually, add entrypoints for init logics, as described [here](#if-the-service-does-not-support-entrypoints-yet-one-needs-to), e.g. like [here](./services/backend/services/v4/compose.base.yaml), including any [ENVs](#docker-compose-env-variables) specific logic. Remember to set the environment variable in the compose.yaml file. See, for example, the frontend [entrypoint](./services/frontend/entrypoints/merge_json.sh) and [compose file](./services/frontend/compose.base.yaml).
4. eventually, add entrypoints for init logics, as described [here](#if-the-service-does-not-support-entrypoints-yet-one-needs-to), e.g. like [here](./services/backend/services/v4/compose.base.yaml), including any [ENVs](#docker-compose-env-variables) specific logic. Remember to set the environment variable in the compose.yaml file.

</details>

Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions services/frontend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The SciCat frontend is the SciCat metadata catalogue web UI, built on top of the

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`.
: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`.

For an extensive list of available options see [here](https://scicatproject.github.io/documentation/Development/v3.x/Configuration.html#scicat-frontend) in the SciCat frontend section.

Expand All @@ -22,6 +22,6 @@ Since there was a small breaking change from `v3` to `v4`, when connecting to th

With `DEV=true`, please use `npm start -- --host 0.0.0.0`. This is to allow traffic from any IP to the `frontend` component and it is necessary since the component runs in the docker network.

Setting the [BACKEND_HTTPS_URL env variable](../../.env) requires changing the `backend` URL used by the `frontend`. This is managed [here](./entrypoints/merge_json.sh).
Setting the [BACKEND_HTTPS_URL env variable](../../.env) requires changing the `backend` URL used by the `frontend`. This is managed [here](../../entrypoints/merge_json.sh).

:warning: When setting `FRONTENT_HTTPS_URL` it is likely you also want to set the `BACKEND_HTTPS_URL`, to allow the communication between the two wherever the browser is accessed.
2 changes: 1 addition & 1 deletion services/frontend/compose.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
- ${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
- ${PWD}/entrypoints/merge_json.sh:/docker-entrypoints/1.sh
entrypoint: loop_entrypoints.sh
command: nginx -g "daemon off;"
labels:
Expand Down
2 changes: 1 addition & 1 deletion services/frontend/compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- frontend_dev:/frontend
- ${PWD}/entrypoints/infinite_loop.sh:/usr/local/bin/infinite_loop.sh
- ${PWD}/entrypoints/setup_git.sh:/docker-entrypoints/0.sh
- ./entrypoints/tests.sh:/docker-entrypoints/2.sh
- ${PWD}/entrypoints/karma_tests.sh:/docker-entrypoints/2.sh
labels:
- traefik.http.services.frontend.loadbalancer.server.port=4200
healthcheck:
Expand Down
4 changes: 2 additions & 2 deletions services/landingpage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The SciCat provides standardised search on published datasets via this LandingPa

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`.
: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

Expand All @@ -16,7 +16,7 @@ For an explanation of how setting `BE_VERSION` changes the environment creation

## 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).
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.

Expand Down
2 changes: 1 addition & 1 deletion services/landingpage/compose.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
- ./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
- ${PWD}/entrypoints/merge_json.sh:/docker-entrypoint.d/0.sh
profiles:
- search
restart: on-failure
Expand Down
4 changes: 2 additions & 2 deletions services/landingpage/compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ services:
- ${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
- ${PWD}/entrypoints/merge_json.sh:/docker-entrypoints/1.sh
- ${PWD}/entrypoints/karma_tests.sh:/docker-entrypoints/2.sh
entrypoint: loop_entrypoints.sh
command: infinite_loop.sh
labels:
Expand Down
6 changes: 0 additions & 6 deletions services/landingpage/entrypoints/merge_json.sh

This file was deleted.

5 changes: 0 additions & 5 deletions services/landingpage/entrypoints/tests.sh

This file was deleted.

0 comments on commit dc327d5

Please sign in to comment.