Name Last Update
bin Loading commit data...
cache Loading commit data...
data/catalog Loading commit data...
notebooks Loading commit data...
resources-tests Loading commit data...
resources Loading commit data...
spec Loading commit data...
tests Loading commit data...
web Loading commit data...
.dockerignore Loading commit data...
.gitignore Loading commit data...
.gitlab-ci.yml Loading commit data...
CHANGELOG.md Loading commit data...
DEV.md Loading commit data...
Dockerfile Loading commit data...
LICENSE Loading commit data...
README.md Loading commit data...
SPACEWEATHERONLINE.md Loading commit data...
TODO.md Loading commit data...
VERSION.txt Loading commit data...
compose.override.yaml-dist Loading commit data...
compose.yaml Loading commit data...
config.yml-dist Loading commit data...
heliopropa.py Loading commit data...
heliopropa.wsgi Loading commit data...
pytest.ini Loading commit data...
requirements-dev.txt Loading commit data...
requirements-nb.txt Loading commit data...
requirements-stable.txt Loading commit data...
requirements-tests.txt Loading commit data...
requirements.txt Loading commit data...

README.md

Heliopropa Web

A web site writen in flask for the visualisation of solarwind propagation simulations.

Builds and serves heliopropa's visualizations.

It's a flask webserver, serving d3.js plots. It also gathers NetCDF data from AMDA, and serves it as CSV to the plotter.

Files Overview

  • config.yml : the main configuration file.
  • web/run.py : the front controller, holding most of the code.
  • web/run.log : you'll find more information about failures in the log.
  • web/view/home.html.jinja2 : the HTML template.
  • web/static/js/swapp.ls : most of the javascript client-side.

Quick Start

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

cp config.yml-dist config.yml
$(EDITOR) config.yml # but defaults should be ok

Python venv

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

Run locally

source venv/bin/activate
DEBUG=true python web/run.py

Then, browse localhost:5000.

Gunicorn and Nginx deployment on OVH for development

see Digital Ocean documentation

wep app service and Gunicorn

see ./resources/heliopropa.service

/etc/systemd/system/heliopropa.service

[Unit]
Description=Gunicorn instance to serve Heliopropa
After=network.target

[Service]
User=debian
Group=www-data
WorkingDirectory= /home/debian/heliopropa/
Environment="PATH=/home/debian/heliopropa/venv/bin/"
ExecStart=/home/debian/heliopropa/venv/bin/gunicorn --workers 3 --bind unix:heliopropa.sock -m 007 web.run:app

[Install]
WantedBy=multi-user.target

Nginx

see ./resources/heliopropa.nginx

/etc/nginx/sites-available/heliopropa

server {
    listen 80;
    server_name heliopropa heliopropa.co-libri.org;

    location / {
        include proxy_params;
        proxy_pass http://unix:/home/debian/heliopropa/heliopropa.sock;
    }
}

Start and Allow at system reboot

sudo systemctl start nginx
sudo systemctl start heliopropa 
sudo systemctl enable heliopropa 

Git hook auto deploy

see ./resources/post-receive.git-hook

Set bare repo with hook on vps

ssh user@vps
git clone --bare path-to-heliopropa-repo heliopropa.git
cd heliopropa.git/hooks
vim post-receive
chmod +x post-receive

Push from dev computer

git remote add helio-dev user@vps:heliopropa.git
git push heliopropa HEAD:DEV