From 0b05d34e3fb902c53becf9a7574eb4bb7d8762fb Mon Sep 17 00:00:00 2001 From: minottic Date: Mon, 25 Nov 2024 11:02:11 +0100 Subject: [PATCH] Add ENV var to control DEV workdir mount to host --- .env | 3 +++ .github/workflows/compose_test.yaml | 1 + .gitignore | 1 + README.md | 3 +++ .../backend/services/v3/services/archivemock/compose.dev.yaml | 2 +- services/compose.dev.yaml | 2 +- 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 92155b9c..2a4c825a 100644 --- a/.env +++ b/.env @@ -16,6 +16,9 @@ BE_VERSION=v4 ## Run SciCat services in DEV mode # DEV=true +## In addition to DEV=true, it mounts the DEV containers' WORKDIR to ./development/${APP}_dev on the host +# DEV_LOCAL=true + ## Set the services HTTPS URL # BACKEND_HTTPS_URL=https://backend-example.com # FRONTEND_HTTPS_URL=https://frontend-example.com diff --git a/.github/workflows/compose_test.yaml b/.github/workflows/compose_test.yaml index bf9607c2..78ed9a17 100644 --- a/.github/workflows/compose_test.yaml +++ b/.github/workflows/compose_test.yaml @@ -154,6 +154,7 @@ jobs: export OIDC_ENABLED=${{ matrix.OIDC_ENABLED }} export BE_VERSION=${{ matrix.BE_VERSION }} export DEV=${{ matrix.DEV }} + export DEV_LOCAL=${{ matrix.DEV }} docker compose --profile '*' \ -f compose.yaml ${DEV:+-f .github/compose.dev.test.yaml} \ up --wait --wait-timeout 600 diff --git a/.gitignore b/.gitignore index b7f1af7f..18666ea9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules/ .ipynb_checkpoints/ *.ipynb .ruff_cache/ +development/ diff --git a/README.md b/README.md index d2f607b1..76c4fecc 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,7 @@ For example `docker compose --profile analysis` sets up a jupyter hub with some | env | `LDAP_ENABLED` | `true`: ldap auth | `''` | * | Creates an LDAP service and sets the BE to use it as authentication backend | | | env | `OIDC_ENABLED` | `true`: oidc auth | `''` | * | Creates an OIDC identity provider and sets the BE to use it as authentication backend | | | env | `DEV` | `true`: backend,frontend,searchapi,archivemock in DEV mode | `''` | * | The SciCat services' environment is prepared to ease the [development in a standardized environment](#dev-configuration) | | +| env | `DEV_LOCAL` | `true`: DEV containers WORKDIR to HOST `./development/${APP}_dev` | `''` | * | It mounts the WORKDIR of every SciCat APP created at `docker compose up` on the host at `./development/${APP}_dev` | | | env | `_HTTPS_URL` | ``: HTTPS termination | `''` | * | Requests the TLS certificate for the URL to LetsEncrypt through the [proxy](#tls-configuration) | | @@ -170,6 +171,8 @@ To provide a consistent environment where developers can work, the `DEV=true` op For standardisation, the [WORKDIR](https://docs.docker.com/reference/dockerfile/#workdir) of the dev containers is set to `/development` and [this preprocessing step](./entrypoints/copy_to_development.sh) copies the files from the image original WORKDIR to `/development`. +When setting `DEV_LOCAL=true`, together with `DEV=true`, all the created `${APP}`s' `/development` folders are mounted to the respective `./development/${APP}_dev` on the host (e.g. for the `frontend`: `./development/frontend_dev`). + Please be patient when using DEV as each container sets the env for dev, including the requirements for testing, which might take a little to finish. To see if any special precaution is required to run the tests, refer to the [compose.dev.test.yaml](.github/compose.dev.test.yaml) file where tests files are referenced and refer to their content. **When DEV=true**, if you want to run tests when the containers start, you can do so by including the `compose.dev.test.yaml` compose file. ```bash docker compose -f compose.yaml -f .github/compose.dev.test.yaml ... diff --git a/services/backend/services/v3/services/archivemock/compose.dev.yaml b/services/backend/services/v3/services/archivemock/compose.dev.yaml index 54336e7c..dd5a4520 100644 --- a/services/backend/services/v3/services/archivemock/compose.dev.yaml +++ b/services/backend/services/v3/services/archivemock/compose.dev.yaml @@ -5,7 +5,7 @@ services: service: web-app labels: !reset null volumes: - - archivemock_dev:/development + - ${DEV_LOCAL:+${PWD}/development/}archivemock_dev:/development user: root volumes: diff --git a/services/compose.dev.yaml b/services/compose.dev.yaml index a77b47e7..341df6d1 100644 --- a/services/compose.dev.yaml +++ b/services/compose.dev.yaml @@ -21,7 +21,7 @@ services: extends: web-app volumes: # This prevents git unpushed changes from being lost on container restart - - ${DEV_VOLUME:-${APP}}_dev:/development + - ${DEV_LOCAL:+${PWD}/development/}${DEV_VOLUME:-${APP}}_dev:/development node-app-from-remote: extends: node-app-from-local image: ''