Skip to content

Commit 5e859fd

Browse files
committed
Remove redundancy from Docker Guide.
1 parent 38134cd commit 5e859fd

2 files changed

Lines changed: 43 additions & 220 deletions

File tree

docker/README-C#.md

Lines changed: 0 additions & 216 deletions
This file was deleted.

docker/README.md

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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,16 +68,56 @@ docker run --rm -ti \
6768
codecompass:dev \
6869
/bin/bash
6970
```
71+
7072
This container will be used in the next subsections to build CodeCompass,
7173
parse a project and start a webserver.
7274

7375
*Note*: you do not have to give the `--publish` option and set the `DATABASE`
7476
environment variable if you do not want to run a webserver. Also you do not
7577
have 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
78118
You can use the `codecompass-build.sh` script inside the container to build,
79119
install and test CodeCompass:
120+
(If you get a timeout error when downloading, put this command before install: NODE_OPTIONS="--max-old-space-size=4096" NEXT_PRIVATE_BUILD_WORKER_TIMEOUT=600)
80121
```bash
81122
# Build CodeCompass.
82123
codecompass-build.sh -j8
@@ -89,24 +130,22 @@ codecompass-build.sh test
89130
```
90131

91132
### How to parse a project
92-
You can parse a project inside a docker container by using the following
133+
You can parse a project (after building it) inside a docker container by using the following
93134
command:
94135
```bash
95136
CodeCompass_parser \
96137
-d "sqlite:database=/CodeCompass/workspace/myproject/data.sqlite" \
97138
-w /CodeCompass/workspace \
98139
-n myproject \
99140
-i /projects/myproject
141+
-f
100142
```
101143

102144
*Note*: the project directory should be mounted inside the container.
103145

104146
### How to start a webserver
105147
You can start a webserver inside the container by using the following command:
106148
```bash
107-
# Create a workspace directory.
108-
mkdir -p /CodeCompass/workspace
109-
110149
# Run the web server.
111150
CodeCompass_webserver \
112151
-w /CodeCompass/workspace

0 commit comments

Comments
 (0)