From 83c0491601133fae6ed73a6f18c7ce1945c89a0d Mon Sep 17 00:00:00 2001 From: fpotier <58594145+fpotier@users.noreply.github.com> Date: Thu, 4 Apr 2024 10:08:00 +0200 Subject: [PATCH] Add `backend-next` container --- README.md | 57 +++++++++++-------- docker-compose.yaml | 1 + services/backendnext/README.md | 22 +++++++ services/backendnext/config/.env | 10 ++++ .../config/functionalAccounts.json | 26 +++++++++ services/backendnext/docker-compose.yaml | 17 ++++++ 6 files changed, 108 insertions(+), 25 deletions(-) create mode 100644 services/backendnext/README.md create mode 100644 services/backendnext/config/.env create mode 100644 services/backendnext/config/functionalAccounts.json create mode 100644 services/backendnext/docker-compose.yaml diff --git a/README.md b/README.md index 8ff779f5..c633506d 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ You can use older versions of SciCat Live by checking out specific tags using `g `v1.0` - the first stable version -Note: older versions might not contain certain functionality (e.g. archival mock in `v1.0`). Be sure to take a look at that version's `README.md` as well. +Note: older versions might not contain certain functionality (e.g. archival mock in `v1.0`). Be sure to take a look at that version's `README.md` as well. ## Steps @@ -23,37 +23,44 @@ Note: older versions might not contain certain functionality (e.g. archival mock ## Default setup -By running `docker-compose up -d` these steps take place: +By running `docker-compose up -d` these steps take place: 1. a [mongodb](./services/mongodb/) container is created with some intial data. 2. a [rabbitmq](./services/rabbitmq/) container is created. 3. the SciCat [backend v3](./services/backend/) container is created and connected to (1) and (2). -4. the SciCat [frontend](./services/frontend/) container is created and connected to (3). -5. the SciCat [PaN searchapi](./services/searchapi/) container is created and connected to (3). -6. a SciCat [archive mock](./services/archivemock/) container is created and connected to (2) and (3). -7. a reverse [proxy](./services/proxy) container is created and routes trafic to (2), (3), (4) and (5) through localhost subdomains, in the form: `http://${service}.localhost` (for the ones of need). The frontend is available at simply `http://localhost`. +4. the SciCat [backend v4](./services/backendnext/) container is created and connected to (1). +5. the SciCat [frontend](./services/frontend/) container is created and connected to (3). +6. the SciCat [PaN searchapi](./services/searchapi/) container is created and connected to (3). +7. a SciCat [archive mock](./services/archivemock/) container is created and connected to (2) and (3). +8. a reverse [proxy](./services/proxy) container is created and routes trafic to (2), (3), (4) and (5) through localhost subdomains, in the form: `http://${service}.localhost` (for the ones of need). The frontend is available at simply `http://localhost`. -Here below we show the dependencies (if `B` depends on `A`, then we visualize as `A --> B`): +Here below we show the dependencies (if `B` depends on `A`, then we visualize as `A --> B`): ```mermaid -graph TD; - subgraph services; - rabbitmq --> archivemock; - rabbitmq --> backend; - mongodb --> backend; - backend --> archivemock; - backend --> frontend; - backend --> searchapi; - end; - proxy -.- backend; - proxy -.- frontend; - proxy -.- searchapi; - proxy -.- rabbitmq; +graph TD + subgraph services + subgraph backends + backend + backend-next + end + + rabbitmq --> archivemock + rabbitmq --> backend + mongodb --> backends + backend --> archivemock + backend --> frontend + backend --> searchapi + end + + proxy -.- backends + proxy -.- frontend + proxy -.- searchapi + proxy -.- rabbitmq ``` ## Select the services -The user can selectively decide the containers to spin up and the dependencies will be resolved accordingly. The available services are in the [services](./services/) folder and called consistently. +The user can selectively decide the containers to spin up and the dependencies will be resolved accordingly. The available services are in the [services](./services/) folder and called consistently. For example, one could decide to only run the `backend` by running (be aware that this will not run the `proxy`, so the service will not be available at `backend.localhost`): @@ -63,26 +70,26 @@ docker-compose up -d backend (or a list of services, for example, with the proxy `docker-compose up -d backend proxy`) -This will run, from the [previous section](#default-setup), (1), (2) and (3) but skip the rest. +This will run, from the [previous section](#default-setup), (1), (2) and (3) but skip the rest. Accordingly, ```sh docker-compose up -d frontend(/searchapi) ``` -Will run, from the [previous section](#default-setup), (1), (2), (3) and (4/(5)) but skip (5/(4)), (6) and (7). +Will run, from the [previous section](#default-setup), (1), (2), (3) and (5/(6)) but skip (4), (6/(5)), (7) and (8). ## Custom configure a service Every service folder (inside the [services](./services/) parent directory) contains its configuration and some instructions, at least for the non third-party containers. -For example, to configure the [frontend](./services/frontend/), the user can change any file in the [frontend config](./services/frontend/config/) folder, for which instructions are available in the [README](./services/frontend/README.md) file. +For example, to configure the [frontend](./services/frontend/), the user can change any file in the [frontend config](./services/frontend/config/) folder, for which instructions are available in the [README](./services/frontend/README.md) file. After any configuration change, `docker-compose up -d` must be rerun, to allow loading the changes. ## Add a new service -To add a new service: +To add a new service: 1. create a dedicated folder in the [services](./services/) one 2. call it as the service should be named 3. create the `docker-compose.yaml` file with the required dependencies (if any) diff --git a/docker-compose.yaml b/docker-compose.yaml index 0d4a1019..3b06c732 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -3,6 +3,7 @@ include: - ./services/mongodb/docker-compose.yaml - ./services/rabbitmq/docker-compose.yaml - ./services/backend/docker-compose.yaml + - ./services/backendnext/docker-compose.yaml - ./services/frontend/docker-compose.yaml - ./services/searchapi/docker-compose.yaml - ./services/archivemock/docker-compose.yaml diff --git a/services/backendnext/README.md b/services/backendnext/README.md new file mode 100644 index 00000000..2a621e9a --- /dev/null +++ b/services/backendnext/README.md @@ -0,0 +1,22 @@ +# [Backend next](https://github.com/SciCatProject/scicat-backend-next) + +The SciCat backend-next or v4 is a rewrite of the original backend, built on top of the NestJS framework. + +## Configuration options + +The backend-next service is mainly configured via environment variables. For an extensive list of available options see [here](https://github.com/SciCatProject/scicat-backend-next/blob/master/README.md). + +### Functional Accounts + +There are a few functional accounts available for handling data: + +| Username | Password | Usage | +| ---------------- | ----------- | ---------------------------- | +| admin | 2jf70TPNZsS | Admin | +| ingestor | aman | Ingest datasets | +| archiveManager | aman | Manage archiving of datasets | +| proposalIngestor | aman | Ingest proposals | + +## Defaul configuration + +In the default configuration folder [config](./config), the backend is set to use the [mongo container](../mongodb/). diff --git a/services/backendnext/config/.env b/services/backendnext/config/.env new file mode 100644 index 00000000..d20f55cf --- /dev/null +++ b/services/backendnext/config/.env @@ -0,0 +1,10 @@ +MONGODB_URI=mongodb://mongodb:27017/dacat-next +SITE=FACILITY +JWT_SECRET=secret +EXPRESS_SESSION_SECRET=secret + +ADMIN_GROUPS=admin +DELETE_GROUPS=buggy +CREATE_DATASET_GROUPS=ingestor +PROPOSAL_GROUPS=proposalingestor +SAMPLE_GROUPS=ingestor diff --git a/services/backendnext/config/functionalAccounts.json b/services/backendnext/config/functionalAccounts.json new file mode 100644 index 00000000..51934f4b --- /dev/null +++ b/services/backendnext/config/functionalAccounts.json @@ -0,0 +1,26 @@ +[ + { + "username": "admin", + "password": "2jf0TPNZsS", + "email": "scicatadmin@your.site", + "role": "admin" + }, + { + "username": "ingestor", + "password": "aman", + "email": "scicatingestor@your.site", + "role": "ingestor" + }, + { + "username": "archiveManager", + "password": "aman", + "email": "scicatarchivemanager@your.site", + "role": "archivemanager" + }, + { + "username": "proposalIngestor", + "password": "aman", + "email": "scicatproposalingestor@your.site", + "role": "proposalingestor" + } +] diff --git a/services/backendnext/docker-compose.yaml b/services/backendnext/docker-compose.yaml new file mode 100644 index 00000000..80de9548 --- /dev/null +++ b/services/backendnext/docker-compose.yaml @@ -0,0 +1,17 @@ +services: + backendnext: + image: ghcr.io/scicatproject/backend-next:v4.4.0 + depends_on: + - mongodb + volumes: + - ./config/functionalAccounts.json:/home/node/app/functionalAccounts.json + env_file: + - ./config/.env + labels: + - traefik.http.routers.backendnext.rule=Host(`backendnext.localhost`) + healthcheck: + test: wget --spider -Y off 'http://127.0.0.1:3000/api/v3/health' + start_period: 5s + interval: 30s + timeout: 10s + retries: 5