Commit a3a7097e254c32dc98cb915c46923bb63ccd79c0

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

Allow docker volume binds

@@ -27,6 +27,10 @@ or major refactoring improvments. @@ -27,6 +27,10 @@ or major refactoring improvments.
27 ### Changed 27 ### Changed
28 ### New 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 ## [2.0.0-alpha.3] - 2023-11-03 - Display Input plot 34 ## [2.0.0-alpha.3] - 2023-11-03 - Display Input plot
31 ### New 35 ### New
32 Show input data along with targets charts 36 Show input data along with targets charts
@@ -13,7 +13,7 @@ RUN pip install --upgrade pip &&\ @@ -13,7 +13,7 @@ RUN pip install --upgrade pip &&\
13 13
14 # Build the whole stuff 14 # Build the whole stuff
15 COPY . . 15 COPY . .
16 -run cp config.yml-dist config.yml 16 +COPY config.yml-dist config.yml
17 17
18 # Allow running outside compose 18 # Allow running outside compose
19 CMD flask --app heliopropa:application run --host=0.0.0.0 19 CMD flask --app heliopropa:application run --host=0.0.0.0
@@ -20,6 +20,34 @@ It also gathers NetCDF data from AMDA, and serves it as CSV to the plotter. @@ -20,6 +20,34 @@ It also gathers NetCDF data from AMDA, and serves it as CSV to the plotter.
20 docker compose build 20 docker compose build
21 docker compose up 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 ## Develop 51 ## Develop
24 52
25 ### Configuration 53 ### Configuration
1 -v2.0.0-alpha.3 1 +v2.0.0-alpha.4
compose.override.yaml-dist 0 → 100644
@@ -0,0 +1,14 @@ @@ -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,6 +8,7 @@ services:
8 command: gunicorn --bind 0.0.0.0:5000 heliopropa:application 8 command: gunicorn --bind 0.0.0.0:5000 heliopropa:application
9 volumes: 9 volumes:
10 - helio_cache:/cache:rw 10 - helio_cache:/cache:rw
  11 + - speasy_cache:/root/.cache/speasy/Cache:rw
11 expose: 12 expose:
12 - 5000 13 - 5000
13 nginx: 14 nginx:
@@ -21,3 +22,4 @@ services: @@ -21,3 +22,4 @@ services:
21 22
22 volumes: 23 volumes:
23 helio_cache: 24 helio_cache:
  25 + speasy_cache: