From 1e30389bd375463c8bf5996931eb0377a1429cd2 Mon Sep 17 00:00:00 2001 From: Carlo Minotti <50220438+minottic@users.noreply.github.com> Date: Wed, 22 May 2024 09:39:58 +0200 Subject: [PATCH] Add jupyter,search profiles to avoid default start --- .github/workflows/docker_compose_test.yaml | 2 +- README.md | 70 +++++++++++++--------- services/jupyter/docker-compose.yaml | 2 + services/searchapi/docker-compose.yaml | 2 + 4 files changed, 47 insertions(+), 29 deletions(-) diff --git a/.github/workflows/docker_compose_test.yaml b/.github/workflows/docker_compose_test.yaml index e94b95c5..11173541 100644 --- a/.github/workflows/docker_compose_test.yaml +++ b/.github/workflows/docker_compose_test.yaml @@ -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 diff --git a/README.md b/README.md index 2addd0a3..21242bf6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # SciCat -Files for running SciCat with docker-compose. +Files for running SciCat with docker compose. ## Tags @@ -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 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 --profile `. + +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 @@ -54,16 +69,16 @@ 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`. @@ -71,41 +86,40 @@ After optionally setting the `BE_VERSION`, one can still select the services to ## 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 @@ -113,12 +127,12 @@ To add a new service (see the [backend v4](./services/backendv4/) for an extensi 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 diff --git a/services/jupyter/docker-compose.yaml b/services/jupyter/docker-compose.yaml index 55d9a23e..10e9b1c6 100644 --- a/services/jupyter/docker-compose.yaml +++ b/services/jupyter/docker-compose.yaml @@ -11,3 +11,5 @@ services: - ./config/notebooks:/home/jovyan/notebooks env_file: - config/.env + profiles: + - analysis diff --git a/services/searchapi/docker-compose.yaml b/services/searchapi/docker-compose.yaml index 18fe1810..d1478c88 100644 --- a/services/searchapi/docker-compose.yaml +++ b/services/searchapi/docker-compose.yaml @@ -7,3 +7,5 @@ services: - traefik.http.routers.searchapi.rule=Host(`searchapi.localhost`) env_file: - ./config/.env + profiles: + - search