This guide is about how to compile Doris using the official compilation image provided. As this image is maintained by the Apache Doris team and is regularly updated with the necessary dependencies, it is the recommended way of compilation for users.
:::tip
Currently, this is not supported in the compute-storage decoupled mode.
:::
In CentOS, execute the following command:
yum install docker
Or refer to the official Docker installation doc.
For different versions of Doris, you need to download different build images. The “apache/doris:build-env-ldb-toolchain-latest” image is used for compiling the latest master code, and it is regularly updated to align with the master.
| Image Version | Doris Version |
|---|---|
| apache/doris:build-env-for-2.0 | 2.0.x |
| apache/doris:build-env-for-2.0-no-avx2 | 2.0.x |
| apache/doris:build-env-ldb-toolchain-latest | master |
| apache/doris:build-env-ldb-toolchain-no-avx2-latest | master |
Take Doris 2.0 as an example, download and check the correponding Docker image.
# Choose docker.io/apache/doris:build-env-for-2.0 $ docker pull apache/doris:build-env-for-2.0 # Check if it is downloaded $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE apache/doris build-env-for-2.0 f29cf1979dba 3 days ago 3.3GB
Note:
apache/doris:build-env-ldb-toolchain-latest is used for compiling the latest master code and is updated along with the master. You can check the update time in the docker/README.md file.java -version, and switch between versions using the following commands. For versions earlier than 2.1 (inclusive), please use JDK 8. For versions later than 3.0 (inclusive) or the master branch, please use JDK 17.# Switch to JDK 8 export JAVA_HOME=/usr/lib/jvm/java-1.8.0 export PATH=$JAVA_HOME/bin/:$PATH # Switch to JDK 17 export JAVA_HOME=/usr/lib/jvm/jdk-17.0.2/ export PATH=$JAVA_HOME/bin/:$PATH
Log in to the host machine and obtain the latest code from the Doris 2.0 branch via git clone.
$ git clone -b branch-2.0 https://github.com/apache/doris.git
After downloading, assume that the source code path is in the “doris-branch-2.0” directory.
# Pre-build a Maven .m2 directory on the host machine to reuse the downloaded Java libraries in Docker. mkdir ~/.m2 # Run the build image docker run -it --network=host --name mydocker -v ~/.m2:/root/.m2 -v ~/doris-branch-2.0:/root/doris-branch-2.0/ apache/doris:build-env-for-2.0 # After successful execution, it should be in the Docker.
Note:
.m2 directory of Maven in the image to a directory on the host machine. This prevents repeated downloads of Maven dependencies each time the image is started for compilation.-p for port mapping and allows sharing the network IP and ports with the host machine.docker run command:| Parameter | Description |
|---|---|
| -v | Mount a storage volume to a specific directory within a container. |
| --name | Specify a name for the container to use the assigned name in future container management. |
| --network | Container network settings: “bridge” uses the Docker daemon‘s specified bridge network, “host” allows the container to use the host’s network, “container:NAME_or_ID” uses the network of another container by sharing IP and port resources, “none” enables the container to use its own network (similar to --net=bridge) without any additional configuration. |
# By default, it builds the AVX2 version. $ sh build.sh # If you need the no AVX2 version, add USE_AVX2=0. $ USE_AVX2=0 sh build.sh # To compile a debug version of BE, add BUILD_TYPE=Debug. $ BUILD_TYPE=Debug sh build.sh
:::tip To check if the machine supports AVX2:
$ cat /proc/cpuinfo | grep avx2 :::
After compilation, the output file is in the output/ directory.
You can create a Doris development environment image by referring to the docker/README.md file.