Skip to content

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:

  1. Docker: Ensure Docker is installed on your system.

  2. Clone NebulaGraph's Source Code: Clone the repository locally using:

    git clone --branch release-3.5 https://github.com/vesoft-inc/nebula.git
    

    This clones the NebulaGraph source code to a subdirectory named nebula.

Compilation steps

  1. 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.

  2. 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 the ubuntu2004 version of the vesoft/nebula-dev compilation image.
    • bash: Executes the bash 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.

  3. Compile NebulaGraph inside the container.

    1. Enter the NebulaGraph source code directory.

      cd nebula
      
    2. Create a build directory and enter it.

      mkdir build && cd build
      
    3. Use CMake to generate the Makefile.

      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 ..
      
      For more on CMake, see CMake Parameters.

    4. 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.

  4. 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.

Next Steps


Last update: August 14, 2023