Skip to content

Commit

Permalink
Add jupyter,search profiles to avoid default start
Browse files Browse the repository at this point in the history
  • Loading branch information
minottic authored May 22, 2024
1 parent 0559168 commit 1e30389
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker_compose_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@ jobs:
- name: Test docker-compose.yaml
run: |-
export BE_VERSION=${{ matrix.BE_VERSION }}
docker compose up --wait --wait-timeout 300
docker compose --profile '*' up --wait --wait-timeout 300
70 changes: 42 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# SciCat

Files for running SciCat with docker-compose.
Files for running SciCat with docker compose.

## Tags

Expand All @@ -18,19 +18,34 @@ Note: older versions might not contain certain functionality (e.g. archival mock
```
2. Run with the following command inside the directory
```sh
docker-compose up -d
docker compose up -d
```

## Default setup

By running `docker-compose up -d` these steps take place:
1. a [mongodb**](./services/mongodb/) container is created with some intial data.
2. the SciCat [backend v4*](./services/backendv4/) container is created and connected to (1).
3. the SciCat [frontend**](./services/frontend/) container is created and connected to (2).
4. the SciCat [PaN searchapi](./services/searchapi/) container is created and connected to (2).
5. a reverse [proxy](./services/proxy) container is created and routes traffic to (2), (3) and (4) through localhost subdomains, in the form: `http://${service}.localhost` (for the ones of need). The frontend is available at simply `http://localhost`.
By running `docker compose up -d` these steps take place:
1. a [mongodb](./services/mongodb/) container is created with some initial data.
2. the SciCat [backend v4](./services/backendv4/) container is created and connected to (1).
3. the SciCat [frontend](./services/frontend/) container is created and connected to (2).
4. a reverse [proxy](./services/proxy) container is created and routes traffic to (2) and (3) through localhost subdomains, in the form: `http://${service}.localhost` (for the ones in 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`):
## Enable extra services

By using [docker compose profiles](https://docs.docker.com/compose/profiles/), some extra services can be enabled, in addition to the default ones. To enable any, run `docker compose --profile <PROFILE> up -d`, or export the `COMPOSE_PROFILES` env variable as described [either](https://docs.docker.com/compose/environment-variables/envvars-precedence/). If needed, the user can specify more than one profile in the CLI by using the flag as `--profile <PROFILE1> --profile <PROFILE1>`.

The available profiles and additional services are:

| Profile | Service |
| ------------ | ----------------- |
| analysis | jupyter |
| search | searchapi |
| '*' | jupyter,searchapi |

In addition to optionally setting the profile(s), the user can still select the service(s) to run as described [here](#select-the-services) and the [BE_VERSION](#select-the-be-version-to-use) to use.

## Dependencies

Here below we show the dependencies, including the ones of the [extra services](#enable-extra-services) (if `B` depends on `A`, then we visualize it as `A --> B`):

```mermaid
graph TD
Expand All @@ -54,71 +69,70 @@ We flag with `*` the services which have extra internal dependencies, which are

## Select the BE version to use

The user can select what backend version to use, by setting the `BE_VERSION` environment variable (either `v3` or `v4`), [either](https://docs.docker.com/compose/environment-variables/envvars-precedence/) setting it in the shell or changing the [.env](./.env#L1) file. If this variable is blank, the system will default to `v4`. The services with `**` have a dependency on the `BE_VERSION` value.
The user can select what backend version to use, by setting the `BE_VERSION` environment variable (either `v3` or `v4`), [either](https://docs.docker.com/compose/environment-variables/envvars-precedence/) setting it in the shell or changing the [.env](./.env#L1) file. If this variable is blank, the system will default to `v4`.

For example, by running:

```sh
export BE_VERSION=v3
docker-compose up -d
docker compose up -d
```

Service (2) of the [default setup](README.md#default-setup) is replaced with the [v3* service](./services/backendv3/) and then steps from (1) to (5) are run.
Service (2) of the [default setup](README.md#default-setup) is replaced with the [v3* service](./services/backendv3/) and then steps from (1) to (4) are run.

For any value of `BE_VERSION`, the `backend` is available at `http://backend.localhost`.

After optionally setting the `BE_VERSION`, one can still select the services to run as described [here](README.md#select-the-services).

## 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 are 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`):

```sh
docker-compose up -d backend
docker compose up -d backend
```

(or a list of services, for example, with the proxy `docker-compose up -d backend proxy`)
(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) and (2) but skip the rest.

Accordingly,
```sh
docker-compose up -d frontend
docker compose up -d frontend
```

Will run, from the [previous section](#default-setup), (1), (2) and (3) but skip (4) and (5).
Will run, from the [previous section](#default-setup), (1), (2) and (4) but skip (5).

And

```sh
docker-compose up -d searchapi
docker compose --profile search up -d searchapi
```

Will run, from the [previous section](#default-setup), (1), (2) and (4) but skip (3) and (5).

Will run, from the [previous section](#default-setup), (1) and (2), skip (3) and (4), and add the `searchapi` service.

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

After any configuration change, `docker-compose up -d` must be rerun, to allow loading the changes.
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 (see the [backend v4](./services/backendv4/) for an extensive example):
1. create a dedicated folder in the [services](./services/) one
2. name it as the service
3. create the `docker-compose.yaml` file with the required dependencies (if any)
4. eventually include any service in (3) which is specific to the service and not shared across the global setup
5. eventually add the condition on the backend version (e.g. [here](./services/frontend/docker-compose.yaml#L14))
6. eventually create a `config` folder if it requires configuration
7. eventually add a `README.md` file in the service
8. include the reference to (3) to the global [docker-compose include list](docker-compose.yaml#L2)
9. eventually update the main [README.md](README.md)
4. eventually, include any service in (3) which is specific to the service and not shared across the global setup
5. eventually, add the condition on the backend version (e.g. [here](./services/frontend/docker-compose.yaml#L14))
6. eventually, create a `config` folder if it requires configuration
7. eventually, add a `README.md` file in the service
8. include the reference to (3) to the global [docker compose include list](docker-compose.yaml#L2)
9. eventually, update the main [README.md](README.md)

## General use of SciCat

Expand Down
2 changes: 2 additions & 0 deletions services/jupyter/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ services:
- ./config/notebooks:/home/jovyan/notebooks
env_file:
- config/.env
profiles:
- analysis
2 changes: 2 additions & 0 deletions services/searchapi/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ services:
- traefik.http.routers.searchapi.rule=Host(`searchapi.localhost`)
env_file:
- ./config/.env
profiles:
- search

0 comments on commit 1e30389

Please sign in to comment.