1 <div align="center"><img height="180" src="https://gitlab.iscpif.fr/gargantext/main/images/logo.png"></div>
4 # Gargantext with Haskell (Backend instance)
6 ![Haskell](https://img.shields.io/badge/Code-Haskell-informational?style=flat&logo=haskell&color=6144b3) ![Stack](https://img.shields.io/badge/Tools-Stack-informational?style=flat&logo=&color=6144b3) ![GHC](https://img.shields.io/badge/Tools-GHC-informational?style=flat&logo=&color=2E677B) ![Nix](https://img.shields.io/badge/Package%20manager-Nix-informational?style=flat&logo=debian&color=6586c8) ![Docker](https://img.shields.io/badge/Tools-Docker-informational?style=flat&logo=docker&color=003f8c)
9 1. [About the project](#about)
10 2. [Example2](#example2)
11 3. [Third Example](#third-example)
12 4. [Fourth Example](#fourth-examplehttpwwwfourthexamplecom)
14 ## About the project <a name="about"></a>
16 GarganText is a collaborative web-decentralized-based macro-service
17 platform for the exploration of unstructured texts. It combines tools
18 from natural language processing, text-data-mining tricks, complex
19 networks analysis algorithms and interactive data visualization tools to
20 pave the way toward new kinds of interactions with your digital corpora.
22 This software is free software, developed and offered by the CNRS
23 Complex Systems Institute of Paris Île-de-France (ISC-PIF) and its
26 GarganText Project: this repo builds the
27 backend for the frontend server built by
28 [backend](https://gitlab.iscpif.fr/gargantext/haskell-gargantext).
33 Disclaimer: this project is still in development, this is work in
34 progress. Please report and improve this documentation if you encounter issues.
42 You need to install [Stack (or Haskell Tool Stack)](https://docs.haskellstack.org/en/stable/) first:
45 curl -sSL https://get.haskellstack.org/ | sh
48 Verify the installation is complete with
56 First install [Nix](https://nixos.org/download.html):
59 $ sh <(curl -L https://nixos.org/nix/install) --daemon
62 Verify the installation is complete
68 > **NOTE INFO (upgrade/downgrade if needed)**
70 > Gargantext works with Nix 2.12.0 (older version than current 2.13.2). To downgrade your Nix version:
72 > `nix-channel --update; nix-env -iA nixpkgs.nixVersions.nix_2_12 nixpkgs.cacert; systemctl daemon-reload; systemctl restart nix-daemon`
74 > Upgrading Nix: https://nixos.org/manual/nix/unstable/installation/upgrading.html
77 ### 3. Build Core Code
79 NOTE: Default build (with optimizations) requires large amounts of RAM
80 (16GB at least). To avoid heavy compilation times and swapping out your
81 machine, it is recommended to `stack build` with the `--fast-` flag,
85 stack --nix build --fast
90 stack --docker build --fast
106 curl -sSL https://gitlab.iscpif.fr/gargantext/haskell-gargantext/raw/dev/devops/docker/docker-install | sh
112 curl -sSL https://gitlab.iscpif.fr/gargantext/haskell-gargantext/raw/dev/devops/debian/install | sh
118 curl -sSL https://gitlab.iscpif.fr/gargantext/haskell-gargantext/raw/dev/devops/ubuntu/install | sh
123 1. CoreNLP is needed (EN and FR); This dependency will not be needed soon.
126 ./devops/install-corenlp
128 Note: if necessary change permission (```sudo chmod 755 ./devops/install-corenlp```)
130 ### Launch Gargantext (It should have been initialized first)
131 Run from haskell-gargantext/devops/docker$
140 ~/.local/bin/gargantext-init "gargantext.ini"
142 Or for Docker env, first create the appropriate image:
146 docker build -t cgenie/stack-build:lts-18.12-garg .
152 stack --docker exec gargantext-init -- gargantext.ini
159 Run PostgreSQL first:
166 Initialization schema should be loaded automatically (from `devops/postgres/schema.sql`).
170 ##### Fix the passwords
172 Change the passwords in gargantext.ini_toModify then move it:
175 cp gargantext.ini_toModify gargantext.ini
177 (`.gitignore` avoids adding this file to the repository by mistake)
182 Users have to be created first (`user1` is created as instance):
186 ~/.local/bin/gargantext-init "gargantext.ini"
189 For Docker env, first create the appropriate image:
193 docker build -t cgenie/stack-build:lts-18.12-garg .
199 stack --docker exec gargantext-init -- gargantext.ini
204 You can import some data with:
206 docker run --rm -it -p 9000:9000 cgenie/corenlp-garg
207 stack exec gargantext-import -- "corpusCsvHal" "user1" "IMT3" gargantext.ini 10000 ./1000.csv
212 It is also possible to build everything with [Nix](https://nixos.org/) instead of Docker:
215 stack --nix exec gargantext-import -- "corpusCsvHal" "user1" "IMT3" gargantext.ini 10000 ./1000.csv
216 stack --nix exec gargantext-server -- --ini gargantext.ini --run Prod
221 ### Multi-User with Graphical User Interface (Server Mode)
224 ~/.local/bin/stack --docker exec gargantext-server -- --ini "gargantext.ini" --run Prod
227 Then you can log in with `user1` / `1resu`.
230 ### Command Line Mode tools
232 #### Simple cooccurrences computation and indexation from a list of Ngrams
235 stack --docker exec gargantext-cli -- CorpusFromGarg.csv ListFromGarg.csv Ouput.json
238 ### Analyzing the ngrams table repo
240 We store the repository in directory `repos` in the [CBOR](https://cbor.io/)
241 file format. To decode it to JSON and analyze, say, using
242 [jq](https://shapeshed.com/jq-json/), use the following command:
245 cat repos/repo.cbor.v5 | stack --nix exec gargantext-cbor2json | jq .
249 To build documentation, run:
252 stack --docker build --haddock --no-haddock-deps --fast
255 (in `.stack-work/dist/x86_64-linux-nix/Cabal-3.2.1.0/doc/html/gargantext`).
259 Some introspection information.
261 Playground is located at http://localhost:8008/gql
263 ### List all GraphQL types in the Playground
275 ### List details about a type in GraphQL
279 __type(name:"User") {
292 ### Upgrading using Docker
294 https://www.cloudytuts.com/tutorials/docker/how-to-upgrade-postgresql-in-docker-and-kubernetes/
296 To upgrade PostgreSQL in Docker containers, for example from 11.x to 14.x, simply run:
298 docker exec -it <container-id> pg_dumpall -U gargantua > 11-db.dump
301 Then, shut down the container, replace `image` section in
302 `devops/docker/docker-compose.yaml` with `postgres:14`. Also, it is a good practice to create a new volume, say `garg-pgdata14` and bind the new container to it. If you want to keep the same volume, remember about removing it like so:
304 docker-compose rm postgres
305 docker volume rm docker_garg-pgdata
308 Now, start the container and execute:
310 # need to drop the empty DB first, since schema will be created when restoring the dump
311 docker exec -i <new-container-id> dropdb -U gargantua gargandbV5
312 # recreate the db, but empty with no schema
313 docker exec -i <new-container-id> createdb -U gargantua gargandbV5
314 # now we can restore the dump
315 docker exec -i <new-container-id> psql -U gargantua -d gargandbV5 < 11-db.dump
320 There is a solution using pgupgrade_cluster but you need to manage the
321 clusters version 14 and 13. Hence here is a simple solution to upgrade.
323 First save your data:
326 pg_dumpall > gargandb.dump
331 sudo apt install postgresql-server-14 postgresql-client-14
332 sudo apt remove --purge postgresql-13
340 Maybe you need to restore the gargantua password
342 ALTER ROLE gargantua PASSWORD 'yourPasswordIn_gargantext.ini'
344 Maybe you need to change the port to 5433 for database connection in
345 your gargantext.ini file.