Skip to content

Commit

Permalink
Add backend-next container
Browse files Browse the repository at this point in the history
  • Loading branch information
fpotier authored Apr 4, 2024
1 parent a5cd639 commit 83c0491
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 25 deletions.
57 changes: 32 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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`):

Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions services/backendnext/README.md
Original file line number Diff line number Diff line change
@@ -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/).
10 changes: 10 additions & 0 deletions services/backendnext/config/.env
Original file line number Diff line number Diff line change
@@ -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
26 changes: 26 additions & 0 deletions services/backendnext/config/functionalAccounts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"username": "admin",
"password": "2jf0TPNZsS",
"email": "[email protected]",
"role": "admin"
},
{
"username": "ingestor",
"password": "aman",
"email": "[email protected]",
"role": "ingestor"
},
{
"username": "archiveManager",
"password": "aman",
"email": "[email protected]",
"role": "archivemanager"
},
{
"username": "proposalIngestor",
"password": "aman",
"email": "[email protected]",
"role": "proposalingestor"
}
]
17 changes: 17 additions & 0 deletions services/backendnext/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 83c0491

Please sign in to comment.