From 632f0a544ff4e7511004a3dcb5cf745d03de3586 Mon Sep 17 00:00:00 2001 From: LakatosMark1 <118832304+LakatosMark1@users.noreply.github.com> Date: Sun, 30 Nov 2025 10:33:24 +0100 Subject: [PATCH 1/9] Update Dockerfile for postgresql usage CodeCompass C# plugin at the moment only can use postgres --- docker/dev/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index 3adcf5d51..30785fcf8 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -64,13 +64,13 @@ COPY docker/dev/codecompass-build.sh /usr/local/bin RUN chmod +x /usr/local/bin/codecompass-build.sh # Setting the environment. -ENV DATABASE=sqlite \ +ENV DATABASE=pgsql \ BUILD_TYPE=Release \ BUILD_DIR=/CodeCompass/build \ INSTALL_DIR=/CodeCompass/install \ SOURCE_DIR=/CodeCompass/CodeCompass \ TEST_WORKSPACE=/CodeCompass/test_workspace \ - TEST_DB="sqlite:database=$TEST_WORKSPACE/cc_test.sqlite" \ + TEST_DB="pgsql:database=$TEST_WORKSPACE/cc_test.pgsql" \ WITH_AUTH="plain;ldap" \ LLVM_DIR=/usr/lib/llvm-15/cmake \ Clang_DIR=/usr/lib/cmake/clang-15 \ From ea4ce6c5e59cb3980b88e080f394cebccd198940 Mon Sep 17 00:00:00 2001 From: LakatosMark1 <118832304+LakatosMark1@users.noreply.github.com> Date: Sun, 30 Nov 2025 11:41:08 +0100 Subject: [PATCH 2/9] Update README.md Updated readme for postgresql usage. --- docker/README.md | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/docker/README.md b/docker/README.md index f830c4b08..56c9404ce 100644 --- a/docker/README.md +++ b/docker/README.md @@ -31,6 +31,9 @@ Table of Contents * [Build image for development](#build-image-for-development) * [How to use docker to develop CodeCompass](#how-to-use-docker-to-develop-codecompass) * [Build, install and test CodeCompass](#build-install-and-test-codecompass) + * [Make a Postgresql container](#make-a-postgresql-container) + * [Create a network and connect CodeCompass and Postgres](#create-a-network-and-connect-codecompass) + * [Create a Postgres user](#create-a-postgres-user) * [How to parse a project](#how-to-parse-a-project) * [How to start a webserver](#how-to-start-a-webserver) * [Deployment](#deployment) @@ -60,7 +63,7 @@ First, you have to start a docker container from this image, which will mount your CodeCompass directory from your host and starts a shell: ```bash docker run --rm -ti \ - --env DATABASE=sqlite --env BUILD_TYPE=Release \ + --env DATABASE=pgsql --env BUILD_TYPE=Release \ --volume /path/to/host/CodeCompass:/CodeCompass \ --volume /path/to/your/host/project:/projects/myproject \ -p 8001:8080 \ @@ -77,6 +80,7 @@ have to mount a project directory if you do not want to parse it later. ### Build, install and test CodeCompass You can use the `codecompass-build.sh` script inside the container to build, install and test CodeCompass: +(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) ```bash # Build CodeCompass. codecompass-build.sh -j8 @@ -88,15 +92,48 @@ codecompass-build.sh install codecompass-build.sh test ``` +### Make a Postgresql container +You need to create a PostgreSQL container that CodeCompass can communicate with. +(postgres is the image name and :15 is the specific version) +```bash +docker run \ + --name postgres_container \ + -e POSTGRES_PASSWORD=root_password \ + -d \ + -p 5432:5432 \ + postgres:15 +``` + +### Create a network and connect CodeCompass and Postgres +Run the containers and connect them to a nework +```bash +docker network create my_network +docker network connect my_network postgres_name +docker network connect my_network codecompass_container +``` +### Create a Postgres user +You need to create a Postgres user and give it admin rights. +(Run these commands from the host computer) +```bash +# 1. Create user "your_user" with password "your_password" +docker exec -it postgres_container psql -U postgres -d postgres -c "CREATE USER your_user WITH PASSWORD 'your_password';" + +# 2. Adunk neki Superuser jogot (hogy biztosan tudjon adatbázist írni/olvasni) +docker exec -it postgres_container psql -U postgres -d postgres -c "ALTER USER your_user WITH SUPERUSER;" +``` + ### How to parse a project You can parse a project inside a docker container by using the following command: +(The project must be built before parsing.) ```bash CodeCompass_parser \ - -d "sqlite:database=/CodeCompass/workspace/myproject/data.sqlite" \ + -d "pgsql:database=myproject;host=codecompass-postgres;port=5432;user=your_user;password=your_password" \ -w /CodeCompass/workspace \ -n myproject \ -i /projects/myproject + -b /projects/myproject/projectname/bin/Debug \ + -f ``` *Note*: the project directory should be mounted inside the container. @@ -104,9 +141,6 @@ CodeCompass_parser \ ### How to start a webserver You can start a webserver inside the container by using the following command: ```bash -# Create a workspace directory. -mkdir -p /CodeCompass/workspace - # Run the web server. CodeCompass_webserver \ -w /CodeCompass/workspace From 40a16a49ebf92c98b11a84a04225ef1ce0f1dcf5 Mon Sep 17 00:00:00 2001 From: LakatosMark1 <118832304+LakatosMark1@users.noreply.github.com> Date: Sun, 30 Nov 2025 11:42:14 +0100 Subject: [PATCH 3/9] Update README.md --- docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/README.md b/docker/README.md index 56c9404ce..5bf46045d 100644 --- a/docker/README.md +++ b/docker/README.md @@ -32,7 +32,7 @@ Table of Contents * [How to use docker to develop CodeCompass](#how-to-use-docker-to-develop-codecompass) * [Build, install and test CodeCompass](#build-install-and-test-codecompass) * [Make a Postgresql container](#make-a-postgresql-container) - * [Create a network and connect CodeCompass and Postgres](#create-a-network-and-connect-codecompass) + * [Create a network and connect CodeCompass and Postgres](#create-a-network-and-connect-codecompass-and-postgres) * [Create a Postgres user](#create-a-postgres-user) * [How to parse a project](#how-to-parse-a-project) * [How to start a webserver](#how-to-start-a-webserver) From d8facfbafe9092150247e4a971e4cbf9eaa2d875 Mon Sep 17 00:00:00 2001 From: LakatosMark1 <118832304+LakatosMark1@users.noreply.github.com> Date: Sat, 27 Dec 2025 17:40:59 +0100 Subject: [PATCH 4/9] Update README.md --- docker/README.md | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docker/README.md b/docker/README.md index 5bf46045d..191156779 100644 --- a/docker/README.md +++ b/docker/README.md @@ -115,11 +115,8 @@ docker network connect my_network codecompass_container You need to create a Postgres user and give it admin rights. (Run these commands from the host computer) ```bash -# 1. Create user "your_user" with password "your_password" -docker exec -it postgres_container psql -U postgres -d postgres -c "CREATE USER your_user WITH PASSWORD 'your_password';" - -# 2. Adunk neki Superuser jogot (hogy biztosan tudjon adatbázist írni/olvasni) -docker exec -it postgres_container psql -U postgres -d postgres -c "ALTER USER your_user WITH SUPERUSER;" +# Create user "your_user" with password "your_password" and give Superuser rights +docker exec -it postgres_container psql -U postgres -d postgres -c "CREATE USER your_user WITH PASSWORD 'your_password' SUPERUSER;" ``` ### How to parse a project From 9c6ecca6fe523c84c48233ab8588ed6c12c19d8f Mon Sep 17 00:00:00 2001 From: LakatosMark1 <118832304+LakatosMark1@users.noreply.github.com> Date: Sat, 27 Dec 2025 17:41:23 +0100 Subject: [PATCH 5/9] Create README-C# --- docker/README-C# | 214 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 214 insertions(+) create mode 100644 docker/README-C# diff --git a/docker/README-C# b/docker/README-C# new file mode 100644 index 000000000..191156779 --- /dev/null +++ b/docker/README-C# @@ -0,0 +1,214 @@ +# Docker + +[![Docker](/doc/images/docker.jpg)](https://www.docker.com/) + +Docker related scripts and config files are under [CodeCompass/docker](/docker). +After navigating to this directory you can use the build scripts with the +commands below. + +:warning: When using Docker to build CodeCompass it is very important to have +the following filesystem layout: + +``` +... + `-CodeCompass + |-CodeCompass # Source code from Git. + | `-docker # Docker related files. + | `-dev # Docker files for development. + | `-web # Docker files for deployment. + |-build # CMake runs here. + |-install # CodeCompass goes here. + `-workspace # Parsed projects' workspace directory. +``` + +The scripts assume this layout. The `build` and `install` directories will be +generated to the parent directory of `CodeCompass` directory containing the +source code. The `workspace` directory should be created manually. + +Table of Contents +================= +* [Development](#development) + * [Build image for development](#build-image-for-development) + * [How to use docker to develop CodeCompass](#how-to-use-docker-to-develop-codecompass) + * [Build, install and test CodeCompass](#build-install-and-test-codecompass) + * [Make a Postgresql container](#make-a-postgresql-container) + * [Create a network and connect CodeCompass and Postgres](#create-a-network-and-connect-codecompass-and-postgres) + * [Create a Postgres user](#create-a-postgres-user) + * [How to parse a project](#how-to-parse-a-project) + * [How to start a webserver](#how-to-start-a-webserver) +* [Deployment](#deployment) + * [Build image for runtime](#build-image-for-runtime) + * [Build image for webserver](#build-image-for-webserver) + * [How to use the webserver executing container](#how-to-use-the-webserver-executing-container) +* [Official DockerHub images](#official-dockerhub-images) + +# Development +## Build image from development +Build the development environment image. The tag name is important! +**It is very important to give this command from the top level directory of the +CodeCompass source.** + +``` +cd CodeCompass +docker build -t codecompass:dev --file docker/dev/Dockerfile . +``` + +See more information [below](#how-to-use-docker-to-develop-codecompass) how to +use this image to develop CodeCompass. + +## How to use docker to develop CodeCompass +You can use the `codecompass:dev` image created +[above](#build-image-for-development) to develop CodeCompass. +First, you have to start a docker container from this image, which will mount +your CodeCompass directory from your host and starts a shell: +```bash +docker run --rm -ti \ + --env DATABASE=pgsql --env BUILD_TYPE=Release \ + --volume /path/to/host/CodeCompass:/CodeCompass \ + --volume /path/to/your/host/project:/projects/myproject \ + -p 8001:8080 \ + codecompass:dev \ + /bin/bash +``` +This container will be used in the next subsections to build CodeCompass, +parse a project and start a webserver. + +*Note*: you do not have to give the `--publish` option and set the `DATABASE` +environment variable if you do not want to run a webserver. Also you do not +have to mount a project directory if you do not want to parse it later. + +### Build, install and test CodeCompass +You can use the `codecompass-build.sh` script inside the container to build, +install and test CodeCompass: +(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) +```bash +# Build CodeCompass. +codecompass-build.sh -j8 + +# Install CodeCompass. +codecompass-build.sh install + +# Run tests. +codecompass-build.sh test +``` + +### Make a Postgresql container +You need to create a PostgreSQL container that CodeCompass can communicate with. +(postgres is the image name and :15 is the specific version) +```bash +docker run \ + --name postgres_container \ + -e POSTGRES_PASSWORD=root_password \ + -d \ + -p 5432:5432 \ + postgres:15 +``` + +### Create a network and connect CodeCompass and Postgres +Run the containers and connect them to a nework +```bash +docker network create my_network +docker network connect my_network postgres_name +docker network connect my_network codecompass_container +``` +### Create a Postgres user +You need to create a Postgres user and give it admin rights. +(Run these commands from the host computer) +```bash +# Create user "your_user" with password "your_password" and give Superuser rights +docker exec -it postgres_container psql -U postgres -d postgres -c "CREATE USER your_user WITH PASSWORD 'your_password' SUPERUSER;" +``` + +### How to parse a project +You can parse a project inside a docker container by using the following +command: +(The project must be built before parsing.) +```bash +CodeCompass_parser \ + -d "pgsql:database=myproject;host=codecompass-postgres;port=5432;user=your_user;password=your_password" \ + -w /CodeCompass/workspace \ + -n myproject \ + -i /projects/myproject + -b /projects/myproject/projectname/bin/Debug \ + -f +``` + +*Note*: the project directory should be mounted inside the container. + +### How to start a webserver +You can start a webserver inside the container by using the following command: +```bash +# Run the web server. +CodeCompass_webserver \ + -w /CodeCompass/workspace +``` + +# Deployment + +## Build image for runtime +For a production environment you can build and use the runtime environment image, +which contains the built CodeCompass binaries and their dependencies: +```bash +docker build -t codecompass:runtime --no-cache --file docker/runtime/Dockerfile . +``` + +By default this image download the `master` branch of the CodeCompass GitHub +repository and build it in `Release` mode with `sqlite` database configuration. +You can override these default values through the following build-time +variables: + +| Variable | Meaning | +| -------------------- | ---------------------------------------- | +| `CC_REPO_URL` | The URL of the CodeCompass repository to use. | +| `CC_VERSION` | The branch, version hash or tag of the CodeCompass repository to use. | +| `CC_DATABASE`| Database type. Possible values are **sqlite**, **pgsql**. | +| `CC_BUILD_TYPE` | Specifies the build type. Supported values are **`Debug`** and **`Release`**. | + +The below example builds the `codecompass:runtime` image with *pgsql* configuration: +```bash +docker build -t codecompass:runtime --build-arg CC_DATABASE=pgsql \ + --no-cache --file docker/runtime/Dockerfile . +``` + +*Note*: the `codecompass:dev` is a prerequisite to build the `codecompass:runtime` image. + +## Build image for webserver +You can use the `codecompass:runtime` image created +[above](#build-image-for-runtime) to build an executing container for the webserver: +```bash +docker build -t codecompass:web --no-cache --file docker/web/Dockerfile . +``` + +See more information [below](#how-to-run-codecompass-webserver-in-docker) how +to use this image to start a CodeCompass webserver. + +### How to use the webserver executing container +You can use the `codecompass:web` image to start a CodeCompass webserver. +For this run the following command: +```bash +docker run \ + --volume /path/to/host/workspace/:/workspace \ + -p 8010:8080 \ + codecompass:web \ + CodeCompass_webserver -w /workspace +``` + +# Official DockerHub images + +Prebuilt images can be downloaded from DockerHub, from the +[modelcpp/codecompass](https://hub.docker.com/r/modelcpp/codecompass) +repository. + +The following image tags are available: + +| Name | Description | +| ---- | ------------| +| `dev` | Development image | +| `runtime-sqlite` | Runtime image containing CodeCompass binaries built against SQLite | +| `runtime-pgsql` | Runtime image containing CodeCompass binaries built against PostrgreSQL | +| `web-sqlite` | Webserver executing container image built against SQLite | +| `web-pgsql` | Webserver executing container image built against PostgreSQL | + +The default `latest` is an alias to `:runtime-pgsql`. +To download (or update) an image from DockerHub, issue the command +`docker pull modelcpp/codecompass:latest`. (Replace `latest` with the desired tag.) From 7b7730d774b3e2b0db1c0390a92ea19926361d9a Mon Sep 17 00:00:00 2001 From: LakatosMark1 <118832304+LakatosMark1@users.noreply.github.com> Date: Sat, 27 Dec 2025 17:41:41 +0100 Subject: [PATCH 6/9] Rename README-C# to README-C#.md --- docker/{README-C# => README-C#.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docker/{README-C# => README-C#.md} (100%) diff --git a/docker/README-C# b/docker/README-C#.md similarity index 100% rename from docker/README-C# rename to docker/README-C#.md From bf701dea44da439a0f2556567936a8fab36bd9bc Mon Sep 17 00:00:00 2001 From: LakatosMark1 <118832304+LakatosMark1@users.noreply.github.com> Date: Sat, 27 Dec 2025 17:44:34 +0100 Subject: [PATCH 7/9] Update Dockerfile --- docker/dev/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile index 30785fcf8..3adcf5d51 100644 --- a/docker/dev/Dockerfile +++ b/docker/dev/Dockerfile @@ -64,13 +64,13 @@ COPY docker/dev/codecompass-build.sh /usr/local/bin RUN chmod +x /usr/local/bin/codecompass-build.sh # Setting the environment. -ENV DATABASE=pgsql \ +ENV DATABASE=sqlite \ BUILD_TYPE=Release \ BUILD_DIR=/CodeCompass/build \ INSTALL_DIR=/CodeCompass/install \ SOURCE_DIR=/CodeCompass/CodeCompass \ TEST_WORKSPACE=/CodeCompass/test_workspace \ - TEST_DB="pgsql:database=$TEST_WORKSPACE/cc_test.pgsql" \ + TEST_DB="sqlite:database=$TEST_WORKSPACE/cc_test.sqlite" \ WITH_AUTH="plain;ldap" \ LLVM_DIR=/usr/lib/llvm-15/cmake \ Clang_DIR=/usr/lib/cmake/clang-15 \ From 25a266fd5002e9bcf4ba40ddbe3af55175a30226 Mon Sep 17 00:00:00 2001 From: LakatosMark1 <118832304+LakatosMark1@users.noreply.github.com> Date: Sat, 27 Dec 2025 17:54:09 +0100 Subject: [PATCH 8/9] Update README.md --- docker/README.md | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/docker/README.md b/docker/README.md index 191156779..f830c4b08 100644 --- a/docker/README.md +++ b/docker/README.md @@ -31,9 +31,6 @@ Table of Contents * [Build image for development](#build-image-for-development) * [How to use docker to develop CodeCompass](#how-to-use-docker-to-develop-codecompass) * [Build, install and test CodeCompass](#build-install-and-test-codecompass) - * [Make a Postgresql container](#make-a-postgresql-container) - * [Create a network and connect CodeCompass and Postgres](#create-a-network-and-connect-codecompass-and-postgres) - * [Create a Postgres user](#create-a-postgres-user) * [How to parse a project](#how-to-parse-a-project) * [How to start a webserver](#how-to-start-a-webserver) * [Deployment](#deployment) @@ -63,7 +60,7 @@ First, you have to start a docker container from this image, which will mount your CodeCompass directory from your host and starts a shell: ```bash docker run --rm -ti \ - --env DATABASE=pgsql --env BUILD_TYPE=Release \ + --env DATABASE=sqlite --env BUILD_TYPE=Release \ --volume /path/to/host/CodeCompass:/CodeCompass \ --volume /path/to/your/host/project:/projects/myproject \ -p 8001:8080 \ @@ -80,7 +77,6 @@ have to mount a project directory if you do not want to parse it later. ### Build, install and test CodeCompass You can use the `codecompass-build.sh` script inside the container to build, install and test CodeCompass: -(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) ```bash # Build CodeCompass. codecompass-build.sh -j8 @@ -92,45 +88,15 @@ codecompass-build.sh install codecompass-build.sh test ``` -### Make a Postgresql container -You need to create a PostgreSQL container that CodeCompass can communicate with. -(postgres is the image name and :15 is the specific version) -```bash -docker run \ - --name postgres_container \ - -e POSTGRES_PASSWORD=root_password \ - -d \ - -p 5432:5432 \ - postgres:15 -``` - -### Create a network and connect CodeCompass and Postgres -Run the containers and connect them to a nework -```bash -docker network create my_network -docker network connect my_network postgres_name -docker network connect my_network codecompass_container -``` -### Create a Postgres user -You need to create a Postgres user and give it admin rights. -(Run these commands from the host computer) -```bash -# Create user "your_user" with password "your_password" and give Superuser rights -docker exec -it postgres_container psql -U postgres -d postgres -c "CREATE USER your_user WITH PASSWORD 'your_password' SUPERUSER;" -``` - ### How to parse a project You can parse a project inside a docker container by using the following command: -(The project must be built before parsing.) ```bash CodeCompass_parser \ - -d "pgsql:database=myproject;host=codecompass-postgres;port=5432;user=your_user;password=your_password" \ + -d "sqlite:database=/CodeCompass/workspace/myproject/data.sqlite" \ -w /CodeCompass/workspace \ -n myproject \ -i /projects/myproject - -b /projects/myproject/projectname/bin/Debug \ - -f ``` *Note*: the project directory should be mounted inside the container. @@ -138,6 +104,9 @@ CodeCompass_parser \ ### How to start a webserver You can start a webserver inside the container by using the following command: ```bash +# Create a workspace directory. +mkdir -p /CodeCompass/workspace + # Run the web server. CodeCompass_webserver \ -w /CodeCompass/workspace From 38134cd1784acfa3ebde834ebdd789079a8ce36a Mon Sep 17 00:00:00 2001 From: LakatosMark1 <118832304+LakatosMark1@users.noreply.github.com> Date: Sat, 27 Dec 2025 18:03:59 +0100 Subject: [PATCH 9/9] Update README-C#.md --- docker/README-C#.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/README-C#.md b/docker/README-C#.md index 191156779..1d72353ad 100644 --- a/docker/README-C#.md +++ b/docker/README-C#.md @@ -63,7 +63,9 @@ First, you have to start a docker container from this image, which will mount your CodeCompass directory from your host and starts a shell: ```bash docker run --rm -ti \ - --env DATABASE=pgsql --env BUILD_TYPE=Release \ + --env DATABASE=pgsql \ + --env TEST_DB="postgresql://postgres:password@postgres_container:5432/postgres" \ + --env BUILD_TYPE=Release \ --volume /path/to/host/CodeCompass:/CodeCompass \ --volume /path/to/your/host/project:/projects/myproject \ -p 8001:8080 \