From 6b2b485a9b62e1658b49c1fc4a4ceb0c882d7b26 Mon Sep 17 00:00:00 2001 From: "abby.huang" <78209557+abby-cyber@users.noreply.github.com> Date: Mon, 14 Aug 2023 11:13:56 +0800 Subject: [PATCH] add compile using docker (#2223) * add compile using docker * Update 7.compile-using-docker.md --- .../7.compile-using-docker.md | 100 ++++++++++++++++++ mkdocs.yml | 4 +- 2 files changed, 102 insertions(+), 2 deletions(-) create mode 100644 docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/7.compile-using-docker.md diff --git a/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/7.compile-using-docker.md b/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/7.compile-using-docker.md new file mode 100644 index 00000000000..272bb728c1b --- /dev/null +++ b/docs-2.0/4.deployment-and-installation/2.compile-and-install-nebula-graph/7.compile-using-docker.md @@ -0,0 +1,100 @@ + +# 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: + + ```bash + git clone --branch {{nebula.branch}} 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. + + ```bash + docker pull vesoft/nebula-dev:ubuntu2004 + ``` + + Here, we use the official NebulaGraph compilation image, `ubuntu2004`. For different versions, see [nebula-dev-docker](https://github.com/vesoft-inc/nebula-dev-docker/#nebula-graph-development-docker-image). + +2. Start the compilation container. + + ```bash + 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. + + ```docker + cd nebula + ``` + + 2. Create a build directory and enter it. + + ```docker + mkdir build && cd build + ``` + + 3. Use CMake to generate the Makefile. + + ```docker + 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](1.install-nebula-graph-by-compiling-the-source-code.md#cmake_variables). + + 4. Compile NebulaGraph. + + ```docker + # 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`: + + ```docker + make install + ``` + +Once completed, NebulaGraph is compiled and installed in the host directory `/usr/local/nebula`. + +## Next Steps + +- [Start NebulaGraph Service](../manage-service.md) +- [Connect to NebulaGraph](../connect-to-nebula-graph.md) diff --git a/mkdocs.yml b/mkdocs.yml index 864d6e6ac34..8686b45e82f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -459,8 +459,8 @@ nav: - Deploy and install: - Resource preparations: 4.deployment-and-installation/1.resource-preparations.md - Compile and install: - - Compile locally: 4.deployment-and-installation/2.compile-and-install-nebula-graph/1.install-nebula-graph-by-compiling-the-source-code.md -# - Compile using Docker: + - Compile the source: 4.deployment-and-installation/2.compile-and-install-nebula-graph/1.install-nebula-graph-by-compiling-the-source-code.md + - Compile using Docker: 4.deployment-and-installation/2.compile-and-install-nebula-graph/7.compile-using-docker.md - Local single-node installation: - Install using RPM or DEB package: 4.deployment-and-installation/2.compile-and-install-nebula-graph/2.install-nebula-graph-by-rpm-or-deb.md - Install using TAR package: 4.deployment-and-installation/2.compile-and-install-nebula-graph/4.install-nebula-graph-from-tar.md