1 # Gargantext with Haskell (Backend instance)
5 GarganText is a collaborative web-decentralized-based macro-service
6 platform for the exploration of unstructured texts. It combines tools
7 from natural language processing, text-data-mining tricks, complex
8 networks analysis algorithms and interactive data visualization tools to
9 pave the way toward new kinds of interactions with your digital corpora.
11 This software is free software, developed and offered by the CNRS
12 Complex Systems Institute of Paris Île-de-France (ISC-PIF) and its
15 GarganText Project: this repo builds the
16 backend for the frontend server built by
17 [backend](https://gitlab.iscpif.fr/gargantext/haskell-gargantext).
22 Disclaimer: this project is still in development, this is work in
23 progress. Please report and improve this documentation if you encounter issues.
27 You need to install stack first:
30 curl -sSL https://get.haskellstack.org/ | sh
33 Verify the installation is complete with
40 First install [nix](https://nixos.org/guides/install-nix.html):
43 curl -sSL https://nixos.org/nix/install | sh
46 Verify the installation is complete
53 stack --nix build --fast
58 NOTE: Default build (with optimizations) requires large amounts of RAM
59 (16GB at least). To avoid heavy compilation times and swapping out your
60 machine, it is recommended to `stack build` with the `--fast-` flag,
64 stack --nix build --fast
69 stack --docker build --fast
75 curl -sSL https://gitlab.iscpif.fr/gargantext/haskell-gargantext/raw/dev/devops/docker/docker-install | sh
81 curl -sSL https://gitlab.iscpif.fr/gargantext/haskell-gargantext/raw/dev/devops/debian/install | sh
87 curl -sSL https://gitlab.iscpif.fr/gargantext/haskell-gargantext/raw/dev/devops/ubuntu/install | sh
92 1. CoreNLP is needed (EN and FR); This dependency will not be needed soon.
95 ./devops/install-corenlp
103 Run PostgreSQL first:
110 Initialization schema should be loaded automatically (from `devops/postgres/schema.sql`).
114 ##### Fix the passwords
116 Change the passwords in gargantext.ini_toModify then move it:
119 mv gargantext.ini_toModify gargantext.ini
121 (`.gitignore` avoids adding this file to the repository by mistake)
126 Users have to be created first (`user1` is created as instance):
130 ~/.local/bin/gargantext-init "gargantext.ini"
133 For Docker env, first create the appropriate image:
137 docker build -t cgenie/stack-build:lts-18.12-garg .
143 stack --docker exec gargantext-init -- gargantext.ini
148 You can import some data with:
150 docker run --rm -it -p 9000:9000 cgenie/corenlp-garg
151 stack exec gargantext-import -- "corpusCsvHal" "user1" "IMT3" gargantext.ini 10000 ./1000.csv
156 It is also possible to build everything with [Nix](https://nixos.org/) instead of Docker:
159 stack --nix exec gargantext-import -- "corpusCsvHal" "user1" "IMT3" gargantext.ini 10000 ./1000.csv
160 stack --nix exec gargantext-server -- --ini gargantext.ini --run Prod
165 ### Multi-User with Graphical User Interface (Server Mode)
168 ~/.local/bin/stack --docker exec gargantext-server -- --ini "gargantext.ini" --run Prod
171 Then you can log in with `user1` / `1resu`.
174 ### Command Line Mode tools
176 #### Simple cooccurrences computation and indexation from a list of Ngrams
179 stack --docker exec gargantext-cli -- CorpusFromGarg.csv ListFromGarg.csv Ouput.json
182 ### Analyzing the ngrams table repo
184 We store the repository in directory `repos` in the [CBOR](https://cbor.io/)
185 file format. To decode it to JSON and analyze, say, using
186 [jq](https://shapeshed.com/jq-json/), use the following command:
189 cat repos/repo.cbor.v5 | stack --nix exec gargantext-cbor2json | jq .
193 To build documentation, run:
196 stack --docker build --haddock --no-haddock-deps --fast
199 (in `.stack-work/dist/x86_64-linux-nix/Cabal-3.2.1.0/doc/html/gargantext`).
203 Some introspection information.
205 Playground is located at http://localhost:8008/gql
207 ### List all GraphQL types in the Playground
219 ### List details about a type in GraphQL
223 __type(name:"User") {
236 ### Upgrading using Docker
238 https://www.cloudytuts.com/tutorials/docker/how-to-upgrade-postgresql-in-docker-and-kubernetes/
240 To upgrade PostgreSQL in Docker containers, for example from 11.x to 14.x, simply run:
242 docker exec -it <container-id> pg_dumpall -U gargantua > 11-db.dump
245 Then, shut down the container, replace `image` section in
246 `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:
248 docker-compose rm postgres
249 docker volume rm docker_garg-pgdata
252 Now, start the container and execute:
254 # need to drop the empty DB first, since schema will be created when restoring the dump
255 docker exec -i <new-container-id> dropdb -U gargantua gargandbV5
256 # recreate the db, but empty with no schema
257 docker exec -i <new-container-id> createdb -U gargantua gargandbV5
258 # now we can restore the dump
259 docker exec -i <new-container-id> psql -U gargantua -d gargandbV5 < 11-db.dump
264 There is a solution using pgupgrade_cluster but you need to manage the
265 clusters version 14 and 13. Hence here is a simple solution to upgrade.
267 First save your data:
270 pg_dumpall > gargandb.dump
275 sudo apt install postgresql-server-14 postgresql-client-14
276 sudo apt remove --purge postgresql-13
284 Maybe you need to restore the gargantua password
286 ALTER ROLE gargantua PASSWORD 'yourPasswordIn_gargantext.ini'
288 Maybe you need to change the port to 5433 for database connection in
289 your gargantext.ini file.