World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.
Java ai-catalogdata-catalogdatalakefederated-querylakehousemetadatametalakemodel-catalogopendatacatalogskycomputingstratosphere
[#2326] feat(docker): support build with arg platform=all on Doris docker image (#2327)
Kang6ba1a8832e43
diff --git a/dev/docker/build-docker.sh b/dev/docker/build-docker.shindex be00d27f73..fd7abff159 100755--- a/dev/docker/build-docker.sh+++ b/dev/docker/build-docker.sh@@ -80,7 +80,7 @@ elif [ "${component_type}" == "gravitino" ]; then. ${script_dir}/gravitino/gravitino-dependency.shelif [ "${component_type}" == "doris" ]; then. ${script_dir}/doris/doris-dependency.sh --platform ${platform_type}- build_args="--build-arg DORIS_PACKAGE_NAME=${DORIS_PACKAGE_NAME} --build-arg DORIS_FILE_NAME=${DORIS_FILE_NAME}"+ build_args="--build-arg DORIS_VERSION=${DORIS_VERSION}"elseecho "ERROR : ${component_type} is not a valid component type"usagediff --git a/dev/docker/doris/Dockerfile b/dev/docker/doris/Dockerfileindex acf42ad69e..f655d56e59 100644--- a/dev/docker/doris/Dockerfile+++ b/dev/docker/doris/Dockerfile@@ -5,9 +5,8 @@FROM ubuntu:22.04LABEL maintainer="[email protected]"-ARG DORIS_PACKAGE_NAME-ARG DORIS_FILE_NAME-ARG TARGET_ARCH+ARG DORIS_VERSION+ARG TARGETARCHWORKDIR /@@ -42,9 +41,8 @@ RUN ARCH=$(uname -m) && \################################################################################### add files--ADD packages/${DORIS_FILE_NAME} /opt-RUN ln -s /opt/${DORIS_PACKAGE_NAME} ${DORIS_HOME}+ADD packages/doris-${TARGETARCH}.tar.xz /opt/+RUN ln -s /opt/apache-doris-${DORIS_VERSION}-bin-* ${DORIS_HOME}COPY start.sh ${DORIS_HOME}@@ -56,4 +54,4 @@ WORKDIR ${DORIS_HOME}EXPOSE 8030EXPOSE 9030-CMD ["bash", "start.sh"]\ No newline at end of file+CMD ["bash", "start.sh"]diff --git a/dev/docker/doris/doris-dependency.sh b/dev/docker/doris/doris-dependency.shindex 043af530e6..887a890917 100755--- a/dev/docker/doris/doris-dependency.sh+++ b/dev/docker/doris/doris-dependency.sh@@ -8,6 +8,11 @@ doris_dir="$(dirname "${BASH_SOURCE-$0}")"doris_dir="$(cd "${doris_dir}">/dev/null; pwd)"TARGET_ARCH=""+AMD64="amd64"+ARM64="arm64"++DORIS_X64="x64"+DORIS_ARM64="arm64"# Get platform typeif [[ "$1" == "--platform" ]]; then@@ -15,13 +20,13 @@ if [[ "$1" == "--platform" ]]; thenplatform_type="$1"if [[ "${platform_type}" == "linux/amd64" ]]; thenecho "INFO : doris build platform type is ${platform_type}"- TARGET_ARCH="x64"+ TARGET_ARCH="${AMD64}"elif [[ "${platform_type}" == "linux/arm64" ]]; thenecho "INFO : doris build platform type is ${platform_type}"- TARGET_ARCH="arm64"+ TARGET_ARCH="${ARM64}"elif [[ "${platform_type}" == "all" ]]; then- echo "ERROR : doris not support ${platform_type}"- exit 1+ echo "INFO : doris build platform type is ${platform_type}"+ TARGET_ARCH="all"elseecho "ERROR : ${platform_type} is not a valid platform type for doris"usage@@ -29,49 +34,82 @@ if [[ "$1" == "--platform" ]]; thenfishiftelse- echo "ERROR: must specify platform for doris"- exit 1+ TARGET_ARCH="all"fi# Environment variables definitionDORIS_VERSION="1.2.7.1"-DORIS_PACKAGE_NAME="apache-doris-${DORIS_VERSION}-bin-${TARGET_ARCH}"-DORIS_FILE_NAME="${DORIS_PACKAGE_NAME}.tar.xz"-DORIS_DOWNLOAD_URL="https://apache-doris-releases.oss-accelerate.aliyuncs.com/${DORIS_FILE_NAME}"-SHA512SUMS_URL="${DORIS_DOWNLOAD_URL}.sha512"+download_and_check() {+ local arch="${1}"+ local doris_package_arch=""-# Prepare download packages-if [[ ! -d "${doris_dir}/packages" ]]; then- mkdir -p "${doris_dir}/packages"-fi+ if [[ "$arch" == "${ARM64}" ]]; then+ doris_package_arch="${DORIS_ARM64}"+ elif [[ "$arch" == "${AMD64}" ]]; then+ doris_package_arch="${DORIS_X64}"+ else+ echo "ERROR : ${arch} is not a valid arch type for doris"+ exit 1+ fi-if [[ ! -f "${doris_dir}/packages/${DORIS_FILE_NAME}" ]]; then- curl -s -o "${doris_dir}/packages/${DORIS_FILE_NAME}" ${DORIS_DOWNLOAD_URL}-fi+ # Download doris package+ DORIS_PACKAGE_NAME="apache-doris-${DORIS_VERSION}-bin-${doris_package_arch}"+ DORIS_FILE_NAME="${DORIS_PACKAGE_NAME}.tar.xz"+ DORIS_DOWNLOAD_URL="https://apache-doris-releases.oss-accelerate.aliyuncs.com/${DORIS_FILE_NAME}"+ SHA512SUMS_URL="${DORIS_DOWNLOAD_URL}.sha512"-# download sha512sum file-if [[ ! -f "${doris_dir}/packages/${DORIS_FILE_NAME}.sha512" ]]; then- curl -s -o "${doris_dir}/packages/${DORIS_FILE_NAME}.sha512" ${SHA512SUMS_URL}-fi+ download_dir="${doris_dir}/packages/"+ # Prepare download packages+ if [[ ! -d "${download_dir}" ]]; then+ mkdir -p "${download_dir}"+ fi++ if [[ ! -f "${download_dir}/${DORIS_FILE_NAME}" ]]; then+ echo "INFO : Downloading doris package ${download_dir}/${DORIS_FILE_NAME}"+ curl -s -o "${download_dir}/${DORIS_FILE_NAME}" ${DORIS_DOWNLOAD_URL}+ echo "INFO : Downloading doris package done"+ fi-cd "${doris_dir}/packages" || exit 1+ # download sha512sum file+ if [[ ! -f "${download_dir}/${DORIS_FILE_NAME}.sha512" ]]; then+ curl -s -o "${download_dir}/${DORIS_FILE_NAME}.sha512" ${SHA512SUMS_URL}+ fi-# check sha512sum, if check file failed, exit 1+ cd "${download_dir}" || exit 1-if command -v shasum &>/dev/null; then- shasum -c "${DORIS_FILE_NAME}.sha512"-elif command -v sha512sum &>/dev/null; then- sha512sum -c "${DORIS_FILE_NAME}.sha512"-else- cat << EOF- WARN: cannot find shasum or sha512sum command, skip sha512sum check, please check the sha512sum by yourself.- if build Docker image failed, maybe the package is broken.+ # check sha512sum, if check file failed, exit 1+ echo "INFO : Checking sha512sum for ${DORIS_FILE_NAME}"+ if command -v shasum &>/dev/null; then+ shasum -c "${DORIS_FILE_NAME}.sha512"+ elif command -v sha512sum &>/dev/null; then+ sha512sum -c "${DORIS_FILE_NAME}.sha512"+ else+ cat << EOF+ WARN: cannot find shasum or sha512sum command, skip sha512sum check, please check the sha512sum by yourself.+ if build Docker image failed, maybe the package is broken.EOF-fi+ fi++ if [ $? -ne 0 ]; then+ echo "ERROR: check doris package sha512sum failed"+ exit 1+ fi++ # copy doris package and rename to doris-${arch}.tar.xz+ # it's a little trick, because the doris package name for 'amd64' is different as 'x64'+ # rename to x64 can use ADD (instead of COPY) in Dockerfile, this will reduce the image size(about 1.6GB)+ if [[ -f "${download_dir}/doris-${arch}.tar.xz" ]]; then+ rm -f "${download_dir}/doris-${arch}.tar.xz"+ fi++ cp "${DORIS_FILE_NAME}" "doris-${arch}.tar.xz"+}-if [ $? -ne 0 ]; then- echo "ERROR: sha512sum check failed"- exit 1+if [[ "${TARGET_ARCH}" == "all" ]]; then+ download_and_check "${AMD64}"+ download_and_check "${ARM64}"+else+ download_and_check "${TARGET_ARCH}"fi\ No newline at end of file