From 7f400160dbb74e8f08c3df8569fc76bd1c26fd73 Mon Sep 17 00:00:00 2001 From: Richard Hitier Date: Sat, 4 Nov 2023 17:19:45 +0100 Subject: [PATCH] Docker compose local:container bindings --- README.md | 28 ++++++++++++++++++++++++++++ compose.override.yaml-dist | 14 ++++++++++++++ compose.yaml | 2 ++ 3 files changed, 44 insertions(+), 0 deletions(-) create mode 100644 compose.override.yaml-dist diff --git a/README.md b/README.md index 7e0a175..2872888 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,34 @@ It also gathers NetCDF data from AMDA, and serves it as CSV to the plotter. docker compose build docker compose up +## Docker compose configuration + +docker stack mainly consists in two files: + +- `Dockerfile` for the container building +- `compose.yaml` for the volumes configuration and links with nginx service and gunicorn + +### Volumes configuration and `compose.override.yaml` + +You may want to understand where data is stored: + +The web application saves `*.csv` files in the `./cache/` directory, which happens to be a docker volume named `helio_cache` + +The speasy library holds a cache dir located at `container:/root/.cache/speasy/Cache/` which is also mounted as a volume: `speasy_cache` + +Two configuration files are also used: + +- `./config.yml` for the web app +- `${HOME}/.config/speasy/config.ini` for the speasy library + + +You can use the `compose.override.yaml` file to make dynamic links between your local files and the container. +That way you can live edit the config files, and also use already loaded cache directories. + + cp compose.override.yaml-dist compose.override.yaml + ${EDITOR} compose.override.yaml # make sure its ok, comment what you dont need + docker compose up -d + ## Develop ### Configuration diff --git a/compose.override.yaml-dist b/compose.override.yaml-dist new file mode 100644 index 0000000..1fdfb5c --- /dev/null +++ b/compose.override.yaml-dist @@ -0,0 +1,14 @@ +# overriding compose configuration file +# dynamically links files and directories from host to container + +services: + web: + volumes: + # local csv files cache used for the running container + - ./cache:/cache:rw + # local site configuration file used for the running container + - ./config.yml:/config.yml + # local speasy configuration file used for the running container + - ${HOME}/.config/speasy/config.ini:/root/.config/speasy/config.ini + # local speasy cache dir file used for the running container + - ${HOME}/.cache/speasy/Cache:/root/.cache/speasy/Cache:rw diff --git a/compose.yaml b/compose.yaml index 5e24aae..98ef3a4 100644 --- a/compose.yaml +++ b/compose.yaml @@ -8,6 +8,7 @@ services: command: gunicorn --bind 0.0.0.0:5000 heliopropa:application volumes: - helio_cache:/cache:rw + - speasy_cache:/root/.cache/speasy/Cache:rw expose: - 5000 nginx: @@ -21,3 +22,4 @@ services: volumes: helio_cache: + speasy_cache: -- libgit2 0.21.2