Commit a3a7097e254c32dc98cb915c46923bb63ccd79c0

Authored by hitier
2 parents e0554e86 5e936526
Exists in rhitier-dev

Allow docker volume binds

CHANGELOG.md
... ... @@ -27,6 +27,10 @@ or major refactoring improvments.
27 27 ### Changed
28 28 ### New
29 29  
  30 +## [2.0.0-alpha.4] - 2023-11-04 - Docker volume binds
  31 +### New
  32 +Allow to bind local files and dirs to container
  33 +
30 34 ## [2.0.0-alpha.3] - 2023-11-03 - Display Input plot
31 35 ### New
32 36 Show input data along with targets charts
... ...
Dockerfile
... ... @@ -13,7 +13,7 @@ RUN pip install --upgrade pip &&\
13 13  
14 14 # Build the whole stuff
15 15 COPY . .
16   -run cp config.yml-dist config.yml
  16 +COPY config.yml-dist config.yml
17 17  
18 18 # Allow running outside compose
19 19 CMD flask --app heliopropa:application run --host=0.0.0.0
... ...
README.md
... ... @@ -20,6 +20,34 @@ It also gathers NetCDF data from AMDA, and serves it as CSV to the plotter.
20 20 docker compose build
21 21 docker compose up
22 22  
  23 +## Docker compose configuration
  24 +
  25 +docker stack mainly consists in two files:
  26 +
  27 +- `Dockerfile` for the container building
  28 +- `compose.yaml` for the volumes configuration and links with nginx service and gunicorn
  29 +
  30 +### Volumes configuration and `compose.override.yaml`
  31 +
  32 +You may want to understand where data is stored:
  33 +
  34 +The web application saves `*.csv` files in the `./cache/` directory, which happens to be a docker volume named `helio_cache`
  35 +
  36 +The speasy library holds a cache dir located at `container:/root/.cache/speasy/Cache/` which is also mounted as a volume: `speasy_cache`
  37 +
  38 +Two configuration files are also used:
  39 +
  40 +- `./config.yml` for the web app
  41 +- `${HOME}/.config/speasy/config.ini` for the speasy library
  42 +
  43 +
  44 +You can use the `compose.override.yaml` file to make dynamic links between your local files and the container.
  45 +That way you can live edit the config files, and also use already loaded cache directories.
  46 +
  47 + cp compose.override.yaml-dist compose.override.yaml
  48 + ${EDITOR} compose.override.yaml # make sure its ok, comment what you dont need
  49 + docker compose up -d
  50 +
23 51 ## Develop
24 52  
25 53 ### Configuration
... ...
VERSION.txt
1   -v2.0.0-alpha.3
  1 +v2.0.0-alpha.4
... ...
compose.override.yaml-dist 0 → 100644
... ... @@ -0,0 +1,14 @@
  1 +# overriding compose configuration file
  2 +# dynamically links files and directories from host to container
  3 +
  4 +services:
  5 + web:
  6 + volumes:
  7 + # local csv files cache used for the running container
  8 + - ./cache:/cache:rw
  9 + # local site configuration file used for the running container
  10 + - ./config.yml:/config.yml
  11 + # local speasy configuration file used for the running container
  12 + - ${HOME}/.config/speasy/config.ini:/root/.config/speasy/config.ini
  13 + # local speasy cache dir file used for the running container
  14 + - ${HOME}/.cache/speasy/Cache:/root/.cache/speasy/Cache:rw
... ...
docker-compose.yml renamed to compose.yaml
... ... @@ -8,6 +8,7 @@ services:
8 8 command: gunicorn --bind 0.0.0.0:5000 heliopropa:application
9 9 volumes:
10 10 - helio_cache:/cache:rw
  11 + - speasy_cache:/root/.cache/speasy/Cache:rw
11 12 expose:
12 13 - 5000
13 14 nginx:
... ... @@ -21,3 +22,4 @@ services:
21 22  
22 23 volumes:
23 24 helio_cache:
  25 + speasy_cache:
... ...