Compile NebulaGraph using Docker¶
NebulaGraph's source code is written in C++. Compiling NebulaGraph requires certain dependencies which might conflict with host system dependencies, potentially causing compilation failures. Docker offers a solution to this. NebulaGraph provides a Docker image containing the complete compilation environment, ensuring an efficient build process and avoiding host OS conflicts. This guide outlines the steps to compile NebulaGraph using Docker.
Prerequisites¶
Before you begin:
-
Docker: Ensure Docker is installed on your system.
-
Clone NebulaGraph's Source Code: Clone the repository locally using:
git clone --branch release-3.6 https://github.com/vesoft-inc/nebula.git
This clones the NebulaGraph source code to a subdirectory named
nebula
.
Compilation steps¶
-
Pull the NebulaGraph compilation image.
docker pull vesoft/nebula-dev:ubuntu2004
Here, we use the official NebulaGraph compilation image,
ubuntu2004
. For different versions, see nebula-dev-docker. -
Start the compilation container.
docker run -ti \ --security-opt seccomp=unconfined \ -v "$PWD":/home \ -w /home \ --name nebula_dev \ vesoft/nebula-dev:ubuntu2004 \ bash
--security-opt seccomp=unconfined
: Disables the seccomp security mechanism to avoid compilation errors.
-v "$PWD":/home
: Mounts the local path of the NebulaGraph code to the container's/home
directory.
-w /home
: Sets the container's working directory to/home
. Any command run inside the container will use this directory as the current directory.
--name nebula_dev
: Assigns a name to the container, making it easier to manage and operate.
vesoft/nebula-dev:ubuntu2004
: Uses theubuntu2004
version of thevesoft/nebula-dev
compilation image.
bash
: Executes thebash
command inside the container, entering the container's interactive terminal.
After executing this command, you'll enter an interactive terminal inside the container. To re-enter the container, use
docker exec -ti nebula_dev bash
. -
Compile NebulaGraph inside the container.
-
Enter the NebulaGraph source code directory.
cd nebula
-
Create a build directory and enter it.
mkdir build && cd build
-
Use CMake to generate the Makefile.
For more on CMake, see CMake Parameters.cmake -DCMAKE_CXX_COMPILER=$TOOLSET_CLANG_DIR/bin/g++ -DCMAKE_C_COMPILER=$TOOLSET_CLANG_DIR/bin/gcc -DENABLE_WERROR=OFF -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTING=OFF ..
-
Compile NebulaGraph.
# The -j parameter specifies the number of threads to use. # If you have a multi-core CPU, you can use more threads to speed up compilation. make -j2
Compilation might take some time based on your system performance.
-
-
Install the Executables and Libraries.
Post successful compilation, NebulaGraph's binaries and libraries are located in
/home/nebula/build
. Install them to/usr/local/nebula
:make install
Once completed, NebulaGraph is compiled and installed in the host directory /usr/local/nebula
.