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
97 ### Launch Gargantext (It should have been initialized first)
99 haskell-gargantext/devops/docker$ docker-compose up
104 ~/.local/bin/gargantext-init "gargantext.ini"
106 Or for Docker env, first create the appropriate image:
110 docker build -t cgenie/stack-build:lts-18.12-garg .
116 stack --docker exec gargantext-init -- gargantext.ini
122 Run PostgreSQL first:
129 Initialization schema should be loaded automatically (from `devops/postgres/schema.sql`).
133 ##### Fix the passwords
135 Change the passwords in gargantext.ini_toModify then move it:
138 cp gargantext.ini_toModify gargantext.ini
140 (`.gitignore` avoids adding this file to the repository by mistake)
145 Users have to be created first (`user1` is created as instance):
149 ~/.local/bin/gargantext-init "gargantext.ini"
152 For Docker env, first create the appropriate image:
156 docker build -t cgenie/stack-build:lts-18.12-garg .
162 stack --docker exec gargantext-init -- gargantext.ini
167 You can import some data with:
169 docker run --rm -it -p 9000:9000 cgenie/corenlp-garg
170 stack exec gargantext-import -- "corpusCsvHal" "user1" "IMT3" gargantext.ini 10000 ./1000.csv
175 It is also possible to build everything with [Nix](https://nixos.org/) instead of Docker:
178 stack --nix exec gargantext-import -- "corpusCsvHal" "user1" "IMT3" gargantext.ini 10000 ./1000.csv
179 stack --nix exec gargantext-server -- --ini gargantext.ini --run Prod
184 ### Multi-User with Graphical User Interface (Server Mode)
187 ~/.local/bin/stack --docker exec gargantext-server -- --ini "gargantext.ini" --run Prod
190 Then you can log in with `user1` / `1resu`.
193 ### Command Line Mode tools
195 #### Simple cooccurrences computation and indexation from a list of Ngrams
198 stack --docker exec gargantext-cli -- CorpusFromGarg.csv ListFromGarg.csv Ouput.json
201 ### Analyzing the ngrams table repo
203 We store the repository in directory `repos` in the [CBOR](https://cbor.io/)
204 file format. To decode it to JSON and analyze, say, using
205 [jq](https://shapeshed.com/jq-json/), use the following command:
208 cat repos/repo.cbor.v5 | stack --nix exec gargantext-cbor2json | jq .
212 To build documentation, run:
215 stack --docker build --haddock --no-haddock-deps --fast
218 (in `.stack-work/dist/x86_64-linux-nix/Cabal-3.2.1.0/doc/html/gargantext`).
222 Some introspection information.
224 Playground is located at http://localhost:8008/gql
226 ### List all GraphQL types in the Playground
238 ### List details about a type in GraphQL
242 __type(name:"User") {
255 ### Upgrading using Docker
257 https://www.cloudytuts.com/tutorials/docker/how-to-upgrade-postgresql-in-docker-and-kubernetes/
259 To upgrade PostgreSQL in Docker containers, for example from 11.x to 14.x, simply run:
261 docker exec -it <container-id> pg_dumpall -U gargantua > 11-db.dump
264 Then, shut down the container, replace `image` section in
265 `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:
267 docker-compose rm postgres
268 docker volume rm docker_garg-pgdata
271 Now, start the container and execute:
273 # need to drop the empty DB first, since schema will be created when restoring the dump
274 docker exec -i <new-container-id> dropdb -U gargantua gargandbV5
275 # recreate the db, but empty with no schema
276 docker exec -i <new-container-id> createdb -U gargantua gargandbV5
277 # now we can restore the dump
278 docker exec -i <new-container-id> psql -U gargantua -d gargandbV5 < 11-db.dump
283 There is a solution using pgupgrade_cluster but you need to manage the
284 clusters version 14 and 13. Hence here is a simple solution to upgrade.
286 First save your data:
289 pg_dumpall > gargandb.dump
294 sudo apt install postgresql-server-14 postgresql-client-14
295 sudo apt remove --purge postgresql-13
303 Maybe you need to restore the gargantua password
305 ALTER ROLE gargantua PASSWORD 'yourPasswordIn_gargantext.ini'
307 Maybe you need to change the port to 5433 for database connection in
308 your gargantext.ini file.