Skip to content

Commit

Permalink
Add ENV var to control DEV workdir mount to host
Browse files Browse the repository at this point in the history
  • Loading branch information
minottic committed Nov 27, 2024
1 parent 2f31a87 commit 0b05d34
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .github/workflows/compose_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ node_modules/
.ipynb_checkpoints/
*.ipynb
.ruff_cache/
development/
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | `<SERVICE>_HTTPS_URL` | `<URL>`: HTTPS termination | `''` | * | Requests the TLS certificate for the URL to LetsEncrypt through the [proxy](#tls-configuration) | |


Expand All @@ -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 ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion services/compose.dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
Expand Down

0 comments on commit 0b05d34

Please sign in to comment.