@@ -30,6 +30,7 @@ Table of Contents
3030* [ Development] ( #development )
3131 * [ Build image for development] ( #build-image-for-development )
3232 * [ How to use docker to develop CodeCompass] ( #how-to-use-docker-to-develop-codecompass )
33+ * [ Use PostgreSQL and run it in a separate container] ( #use-postgresql-and-run-it-in-a-separate-container )
3334 * [ Build, install and test CodeCompass] ( #build-install-and-test-codecompass )
3435 * [ How to parse a project] ( #how-to-parse-a-project )
3536 * [ How to start a webserver] ( #how-to-start-a-webserver )
@@ -67,13 +68,52 @@ docker run --rm -ti \
6768 codecompass:dev \
6869 /bin/bash
6970```
71+
7072This container will be used in the next subsections to build CodeCompass,
7173parse a project and start a webserver.
7274
7375* Note* : you do not have to give the ` --publish ` option and set the ` DATABASE `
7476environment variable if you do not want to run a webserver. Also you do not
7577have to mount a project directory if you do not want to parse it later.
7678
79+ ### Use PostgreSQL and run it in a separate container
80+ Alternatively, instead of SQLite, you may want to ue PostgreSQL and run the database
81+ engine in a Docker container as well:
82+ ``` bash
83+ docker run --rm -ti \
84+ --env DATABASE=pgsql \
85+ --env TEST_DB=" postgresql://postgres:password@postgres_container:5432/postgres" \
86+ --env BUILD_TYPE=Release \
87+ --volume /path/to/host/CodeCompass:/CodeCompass \
88+ --volume /path/to/your/host/project:/projects/myproject \
89+ -p 8001:8080 \
90+ codecompass:dev \
91+ /bin/bash
92+ ```
93+
94+ You need to create a PostgreSQL container that CodeCompass can communicate with:
95+ ``` bash
96+ docker run \
97+ --name postgres_container \
98+ -e POSTGRES_PASSWORD=root_password \
99+ -d \
100+ -p 5432:5432 \
101+ postgres:15
102+ ```
103+
104+ You also need to create a Postgres user and give it admin rights:
105+ ``` bash
106+ # Create user "your_user" with password "your_password" and give Superuser rights
107+ docker exec -it postgres_container psql -U postgres -d postgres -c " CREATE USER your_user WITH PASSWORD 'your_password' SUPERUSER;"
108+ ```
109+
110+ Finally, create a network and connect CodeCompass and Postgres to it:
111+ ``` bash
112+ docker network create my_network
113+ docker network connect my_network postgres_name
114+ docker network connect my_network codecompass_container
115+ ```
116+
77117### Build, install and test CodeCompass
78118You can use the ` codecompass-build.sh ` script inside the container to build,
79119install and test CodeCompass:
@@ -88,8 +128,11 @@ codecompass-build.sh install
88128codecompass-build.sh test
89129```
90130
131+ * Note* : if you get a timeout error when downloading, add these variable definitions before install:
132+ ` NODE_OPTIONS="--max-old-space-size=4096" NEXT_PRIVATE_BUILD_WORKER_TIMEOUT=600 `
133+
91134### How to parse a project
92- You can parse a project inside a docker container by using the following
135+ You can parse a project (after building it) inside a docker container by using the following
93136command:
94137``` bash
95138CodeCompass_parser \
@@ -104,9 +147,6 @@ CodeCompass_parser \
104147### How to start a webserver
105148You can start a webserver inside the container by using the following command:
106149``` bash
107- # Create a workspace directory.
108- mkdir -p /CodeCompass/workspace
109-
110150# Run the web server.
111151CodeCompass_webserver \
112152 -w /CodeCompass/workspace
0 commit comments