INSTALL.md 2.12 KB

Installation de Plan De Charge

Prérequis

  • python3

Obtenir un répertoire fonctionnel

git clone https://gitlab.irap.omp.eu/PDC-IRAP/pdc-web.git
cd pdc-web

Installer l'environment python

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

Configurer l'application

cp resources/pdc_config.py .
$(EDITOR) pdc_config.py

cp resources/flaskenv .flaskenv

Jouer les tests et exécuter un serveur local

pip install -r requirements-tests.txt
PYTHONPATH=. pytest

# éventuellement voir le taux de couverture
PYTHONPATH=. pytest  --cov=app --cov-report=xml:"coverage.xml" --cov-report=term --junitxml "tests-report.xml" 

# ouvrir un serveur sur localhost:5000
flask run

Configurer apache

Les fichiers concernés:

  • pdc_web.wsgi
  • pdc_config.py

La procédure:

mkdir /var/www/html/pdc-web

cp ./resources/apache2-virtual-host.conf /etc/apache2/sites-available/pdc-web.conf
$(EDITOR) /etc/apache2/sites-available/pdc-web.conf # éditer les paramètres
a2ensite pdc-web 
apachectl restart

Mise à jour

git autodeploy

Les fichiers concernés:

  • scripts/post-deploy.sh
  • resources/post-receive.git-hook

La procédure:

git --work-tree=/var/www/html/pdc-web --git-dir=/path/to/the/repo.git checkout -f master

# make bare repo
git clone --bare /path/to/the/repo.git
# put on hook
cp /path/to/working-directory/resources/post-receive.git-hook repo.git/hooks/post-receive
$(EDITOR) repo.git/hooks/post-receive

git push to repo

Pycharm Integration

As this projects makes use of the application factory pattern, using pycharm requires some tiny configuration effort.

Look at https://flask.palletsprojects.com/en/1.1.x/cli/#pycharm-integration for more details.

But basically, you just have to Edit the Run Configurations, and set the fields:

  • select module name, and set it to 'flask'
  • set Parameters to run

It should read the environment variables

  • FLASK_ENV
  • FLASK_APP

you have previously set in the file .flaskenv

Thats it, run you webapp through PyCharm, enjoy.