biommap/README.md

7.2 KiB

Geonature - Biommap

L'instance Geonature-Citizen de Champs-Libres.

Multi-container instructions

Installation

Clone this repo

 $ git clone git@gitea.champs-libres.be:champs-libres/biommap.git

Get the code (using git-submodule) for : citizen & taxhub.

 $ git submodule update --init --recursive

DB init

Creation of the table referentielsdb that will be used for storing data.

$ docker-compose up -d db
$ docker-compose exec db createdb -U postgres referentielsdb
$ docker-compose exec db psql -U postgres -d referentielsdb -c "CREATE SCHEMA taxonomie"
$ docker-compose exec db psql -d -U postgres -d referentielsdb -c "CREATE EXTENSION postgis"

Build the other containers

$ docker-compose up

Compile the front

$ docker-compose run --rm citizen-front npm install
$ docker-compose run --rm citizen-front npm run build:i18n-ssr

Starting

For starting the application again, you may start the db container first

$ docker-compose up -d db
$ docker-compose up

Misc.

Taxhub

$ docker-compose run taxhub bash install_db.sh
$ docker-compose up -d taxhub

CREATION / Compiation du JS de Taxhub

Mise à jour de nppm.
       $ docker-compose exec -u root taxhub bash
taxhub $ npm install npm@latest -g  # mise à jour de npm

Compilation du code

       $ docker-compose exec taxhub bash
taxhub $ cd static
taxhub $ cp app/constants.js.sample app/constants.js
taxhub $ npm install

Citizen-front

$ docker-compose run --rm citizen-front npm install
$ docker-compose run --rm citizen-front npm run build:i18n-ssr
$ docker-compose up -d citizen-front

Citizen-back

docker-compose up -d citizen-front

nginx

Redirige de 8080 vers autres services :

   - 4000 (citizen-front)
   - 5002 (citizen-back)
   - 5000 (taxon)

Development

Inspect db

There is a pgweb container that allows to inspect the db, at http://localhost:8081/. Use the following credentials to connect:

  • host: db
  • un: postgres
  • pw: postgres
  • dbname: referentielsdb
  • port: 5432
  • SSL mode: disable

Front-end development

In order to interactively edit the js code, the frontend folder is mounted into the frontend container. To interactively develop the frontend code and watch the results, enter the running frontend container and launch ng serve with the following arguments (see http://imaginativethinking.ca/heck-get-connection-reset-peer-containerizing-angular-4-application/ for why the host argument is required):

docker-compose exec citizen-front bash
root@9c0fea7720a0:/home/appuser/citizen/frontend# npm run ng serve -- --host 0.0.0.0 --port 4200 --configuration=fr --poll 2000

But note that for persistently-built frontend files, you must run:

docker-compose exec citizen-front bash
root@9c0fea7720a0:/home/appuser/citizen/frontend# npm run build:i18n-ssr

or npm run build:fr for speeding up.

Back-end development

When developing the app and serving it with docker-compose up, the changes are automatically loaded (meaning, the app is watching the changes). However, it is more practical to change the command of the backend container from command: bash start_gunicorn.sh to command: python wsgi.py in order to have some logs.

Deploiement sur un serveur distant

0) Si on change le fichier app.config.ts

scp patches/frontend/src/conf/app.config.ts.dist user@domain.org:/path/to/app.config.ts

1) Reconstruire l'image front en local

docker-compose build citizen-front
docker login registry.gitlab.com
docker push registry.gitlab.com/champs-libres/geonature-citizen/front

Il est peut-être aussi nécessaire de faire de même pour l'image media.

docker-compose build media
docker login registry.gitlab.com
docker push registry.gitlab.com/champs-libres/geonature-citizen/media

2) Sur le serveur distant

docker pull registry.gitlab.com/champs-libres/geonature-citizen/front
# Rebuild of the front
docker-compose run --rm citizen-front npm run build:i18n-ssr
# Restart the containers
docker-compose up -d db
docker-compose up -d

Troubleshooting

Attention, lorsqu'on envoie des images sur le serveur (avec docker push), celles-ci peuvent être très volumineuses! Il faut vérifier la capacité du serveur (avec df), inspecter les images existantes (docker image ls) et supprimer les anciennes images (docker rmi ...).

Single-container instructions (deprecated)

Installation

$ git submodule update --init --recursive $ docker-compose up -d $ docker-compose exec citizen install/install_app.sh

note: les credentials pour accéder au backend se trouvent dans /home/appuser/citizen/config

Développement

Mise à jour de GeoNature

Certaines modifications sont faites sur le fork de GeoNature-citizen. Pour télécharger la dernièer version, faire:

$ git submodule foreach git pull git@github.com:Champs-Libres/GeoNature-citizen.git champs-libres

Remise en route du service

$ docker-compose up -d $ docker-compose exec citizen sh install/restart.sh

Documentation

$ make doc

Builder le front (pour production) (avant de pouvoir faire le docker up)

$ docker-compose run --rm citizen-front npm install
$ docker-compose run --rm citizen-front npm run build:i18n-ssr
$ docker-compose up -d citizen-front

$ docker-compose exec citizen-front bash appuser@ab136184159a:~/citizen/$ cd frontend appuser@ab136184159a:~/citizen/frontend$ npm run ng build -- --configuration=fr --prod


### Modifier la config du front end

- faire des modifications dans `patches/frontend/conf`
- Builder le front (cfr commande ci-dessus)
- arrêter le container et remise en route du service (cfr commande ci-desssus)

### Modifier les images (e.g., image de fond)

Certaines images sont servies sur api/media, d'autres dans assets!
#### 1) Les images servies sur api/media/

- changer les fichiers dans `patches/frontend/src/assets/`
- copier ces fichiers dans le dossier `media`:

$ docker-compose exec citizen bash appuser@ab136184159a:~/citizen/$ cp -r frontend/src/assets/* media


- arrêter le container et remise en route du service (cfr commande ci-desssus)

#### 2) Les images servies sur assets/

- changer les fichiers dans `patches/frontend/src/assets/`
- Builder le front (cfr commande ci-dessus)
- arrêter le container et remise en route du service (cfr commande ci-desssus)

## Utilisation et configuration

- Interface admin: http://localhost:8080/api/admin
- UN: citizen
- PW: voir le password généré à la fin de l'installation!
### Création d'un programme

La création d'un programme n'est pas encore documentée dans la doc officielle. Remplir les formulaires dans l'admin.

Notes:

- Dans zone géographique, il faut rentrer un fichier geojson. Les limites de la commune de wasseiges peuvent être retrouvées via http://overpass-turbo.eu/s/15qX ou dans `fixtures/geojson/`.

### Création d'un utilisateur

La création d'un utilisateur n'est pas encore documentée dans la doc officielle. On peut s'enregistrer sur le site. Néanmoins, sans serveur SMTP, l'envoi de l'email de confirmation ne fonctionne pas. Il faut alors manuellement **activer** l'utilisateur dans l'admin.