Skip to content

Commit

Permalink
add compile using docker (#2223)
Browse files Browse the repository at this point in the history
* add compile using docker

* Update 7.compile-using-docker.md
  • Loading branch information
abby-cyber authored Aug 14, 2023
1 parent 129cec3 commit 6b2b485
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6b2b485

Please sign in to comment.