README.md 5.5 KB
Newer Older
1
2
# FAIDARE: FAIR Data-finder for Agronomic Research
This application provides web services (based on the BrAPI standard) and a web interface with easy to use filters to facilitates the access to plant datasets from a federation of sources.
Raphaël Flores's avatar
Raphaël Flores committed
3

Célia Michotey's avatar
Célia Michotey committed
4
5
[[_TOC_]]

Raphaël Flores's avatar
Raphaël Flores committed
6
7
## How to contribute

8
9
10
11
Look at the [contribution guide](CONTRIBUTING.md).

## Install development environment

Exbrayat Cédric's avatar
Exbrayat Cédric committed
12
- Install `node` and `yarn`
13

14
Installation via `nvm` is recommended for easier control of installed version:
15
16
17
18
19
20
21
https://github.com/creationix/nvm

```sh
nvm install 10.13.0
nvm use v10.13.0
```

22
- Install JS dependencies
23

24
```sh
Exbrayat Cédric's avatar
Exbrayat Cédric committed
25
26
cd web
yarn
27
28
```

29
- Install latest Java JDK8
30

31
32
See latest instructions for your operating system.

Exbrayat Cédric's avatar
Exbrayat Cédric committed
33
- (Optional) Install `docker`
34
35
36

If you want to run an Elasticsearch and Kibana instance on your machine.
You can use your favorite package manager for that
37
38
39
40


## Run backend development server

41
42
43
44
45
First make sure you have access to an Elasticsearch HTTP API server on `http://127.0.0.1:9200` (either via ssh tunneling or by running a local server).

If you want to run an Elasticsearch server on your development machine you can use the `docker`/`docker-compose` configuration like so:

```sh
Exbrayat Cédric's avatar
Exbrayat Cédric committed
46
docker compose up
47
48
```

49
> This will launch an Elasticsearch server (with port forwarding `9200`) and a Kibana server (with port forwarding `5601`)
50
51
52
53

> **Warning**: This repository does not automatically index data into Elasticsearch, you need to prepare your indices beforehand.


Exbrayat Cédric's avatar
Exbrayat Cédric committed
54
If you just need access to API, you can run:
55
56
57
58
59

```sh
./gradlew bootRun
```

Exbrayat Cédric's avatar
Exbrayat Cédric committed
60
61
62
63
64
65
66
67
If you are developing and need to work on the `web` assets (scripts, styles, etc),
you'll need to run the application with the `dev` profile:

```sh
./gradlew bootRun --args='--spring.profiles.active=dev'
```

Otherwise, for the complete server (backend APIs + web interface), you can run:
68
69

```sh
70
./gradlew assemble && java -jar backend/build/libs/faidare.jar
71
72
```

73
The server should then be accessible at http://localhost:8380/faidare-dev
74

Exbrayat Cédric's avatar
Exbrayat Cédric committed
75
## Build the JS/CSS assets for the Web module
76

Exbrayat Cédric's avatar
Exbrayat Cédric committed
77
78
The `web` directory contains the scripts and styles used by the thymeleaf templates
when a Germplasm, Study or Site page is rendered.
79

Exbrayat Cédric's avatar
Exbrayat Cédric committed
80
The build process for these assets can be run with the following command:
81
82

```sh
Exbrayat Cédric's avatar
Exbrayat Cédric committed
83
84
cd web
yarn watch
85
86
```

Exbrayat Cédric's avatar
Exbrayat Cédric committed
87
88
89
90
91
92
93
94
`yarn watch` automatically picks up the changes in any files,
and rebuild the resulting assets (thanks to Webpack).
Make sure the backend is running with the `dev` profile if you do so (see above),
otherwise the changes won't be shown in the browser.

`yarn watch:prod` is also available to use production settings,
while `yarn build` and `yarn build:prod` do the same but without watching the changes. 

95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
## Harvest

Before all, take care to get data locally before running any indexing script.

### TL;DR

Data indexing to your local Elasticsearch is done using the following command (take care to change the path to local data). Note that your local Elasticsearch instance should be already runing using `docker-compose up`:

```sh
docker run -t --volume /path/to/local/data:/opt/data/ --network=container:elasticsearch-faidare registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:latest -jsonDir /opt/data/ --help
```
Remove the `--help` parameter to run the loading with default params.

### Portability

#### Docker

[TL;DR](#TLDR) section above expects to have an available docker image on the forgemia docker registry. The Gitlab CI rebuil it when needed, but you can update or push such an image using the following commands:

```sh
# build the image
docker build -t registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:latest .

# Login before pushing the image
docker login registry.forgemia.inra.fr/urgi-is/docker-rare -u <your ForgeMIA username>

# push the built image
docker push registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:latest
```

That should ease the indexing of data without having to craft a dedicated environment.

127
128
## GitLab CI

129
130
131
132
133
When creating merge requests on the ForgeMIA GitLab, the GitLab CI will 
automatically run the tests of the project (no need to do anything).

If you want to run the GitLab CI locally, you have to follow this steps:

134
135
1. [Install gitlab-runner](https://docs.gitlab.com/runner/install/)
2. Run the following command (with the correct GnpIS security token):
136

137
138
139
```sh
gitlab-runner exec docker test 
```
140
141
142
143
144
145
146
147
148
149


## Spring Cloud config

On bootstrap, the application will try to connect to a remote Spring Cloud config server
to fetch its configuration.
The details of this remote server are filled in the `bootstrap.yml` file.
By default, it tries to connect to the remote server on http://localhost:8888
but it can of course be changed, or even configured via the `SPRING_CONFIG_URI` environment variable.

150
It will try to fetch the configuration for the application name `faidare`, and the default profile.
151
152
153
154
If such a configuration is not found, it will then fallback to the local `application.yml` properties.
To avoid running the Spring Cloud config server every time when developing the application,
all the properties are still available in `application.yml` even if they are configured on the remote Spring Cloud server as well.

155
The configuration is currently only read on startup,
156
meaning the application has to be rebooted if the configuration is changed on the Spring Cloud server.
157
158
159
160
For a dynamic reload without restarting the application,
see http://cloud.spring.io/spring-cloud-static/Finchley.SR1/single/spring-cloud.html#refresh-scope
to check what has to be changed.

161
162
If you want to use a Spring Cloud configuration server, please refer to
https://spring.io/guides/gs/centralized-configuration/
163