You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kyuubi.apache.org by ch...@apache.org on 2023/02/10 06:28:25 UTC
[kyuubi] branch master updated: [KYUUBI #4184][SUBTASK-1] Refactor docker-image-tool.sh
This is an automated email from the ASF dual-hosted git repository.
chengpan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kyuubi.git
The following commit(s) were added to refs/heads/master by this push:
new 708d982eb [KYUUBI #4184][SUBTASK-1] Refactor docker-image-tool.sh
708d982eb is described below
commit 708d982eb90f2b3e915d3e9ec9fda10932469d9a
Author: zwangsheng <22...@qq.com>
AuthorDate: Fri Feb 10 14:28:14 2023 +0800
[KYUUBI #4184][SUBTASK-1] Refactor docker-image-tool.sh
### _Why are the changes needed?_
See more in #4184
This subtask remove build kyuubi docker image from dev mode(source code).
In follow subtask, will add feature build kyuubi docker image from source code.
### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible
- [ ] Add screenshots for manual tests if appropriate
- [ ] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request
Closes #4217 from zwangsheng/tool/docker-image-tool.
Closes #4184
34c866025 [zwangsheng] Add +x premission for docker-image-tool
97b404db7 [zwangsheng] Copy download spark binary
6f267e221 [zwangsheng] Refactor docker-image-tool.sh
Authored-by: zwangsheng <22...@qq.com>
Signed-off-by: Cheng Pan <ch...@apache.org>
---
bin/docker-image-tool.sh | 71 +++++++++++++++---------------------------------
1 file changed, 22 insertions(+), 49 deletions(-)
diff --git a/bin/docker-image-tool.sh b/bin/docker-image-tool.sh
index e9e4338b5..f3efc8bf5 100755
--- a/bin/docker-image-tool.sh
+++ b/bin/docker-image-tool.sh
@@ -27,19 +27,21 @@ function error {
if [ -z "${KYUUBI_HOME}" ]; then
KYUUBI_HOME="$(cd "`dirname "$0"`"/..; pwd)"
fi
-
-CTX_DIR="$KYUUBI_HOME/target/tmp/docker"
+KYUUBI_IMAGE_NAME="kyuubi"
function is_dev_build {
[ ! -f "$KYUUBI_HOME/RELEASE" ]
}
-function cleanup_ctx_dir {
- if is_dev_build; then
- rm -rf "$CTX_DIR"
- fi
-}
-trap cleanup_ctx_dir EXIT
+if is_dev_build; then
+ cat <<EOF
+ Current docker-image-tool.sh only support build docker image from binary package.
+ You can download Kyuubi binary package from kyuubi web-sit https://kyuubi.apache.org/releases.html.
+ Or you can build binary from source code with $KYUUBI_HOME/build/dist, find more detail about build binary in that script
+
+EOF
+ exit 1
+fi
function image_ref {
local image="$1"
@@ -77,44 +79,13 @@ function resolve_file {
echo $FILE
}
-# Create a smaller build context for docker in dev builds to make the build faster. Docker
-# uploads all of the current directory to the daemon, and it can get pretty big with dev
-# builds that contain test log files and other artifacts.
-#
-# Note: docker does not support symlinks in the build context.
-function create_dev_build_context {(
- set -e
- local BASE_CTX="$CTX_DIR/base"
- mkdir -p "$BASE_CTX/docker"
- cp -r "docker/" "$BASE_CTX/docker"
-
- cp -r "kyuubi-assembly/target/scala-${KYUUBI_SCALA_VERSION}/jars" "$BASE_CTX/jars"
-
- mkdir -p "$BASE_CTX/externals/engines/spark"
- cp "$KYUUBI_HOME/externals/kyuubi-spark-sql-engine/target/kyuubi-spark-sql-engine_${KYUUBI_SCALA_VERSION}-${KYUUBI_VERSION}.jar" "$BASE_CTX/externals/engines/spark"
-
- for other in bin conf; do
- cp -r "$other" "$BASE_CTX/$other"
- done
-)}
-
function img_ctx_dir {
- if is_dev_build; then
- echo "$CTX_DIR/$1"
- else
- echo "$KYUUBI_HOME"
- fi
+ echo "$KYUUBI_HOME"
}
function build {
local BUILD_ARGS
local KYUUBI_ROOT="$KYUUBI_HOME"
-
- if is_dev_build; then
- create_dev_build_context || error "Failed to create docker build context."
- KYUUBI_ROOT="$CTX_DIR/base"
- fi
-
local BUILD_ARGS=(${BUILD_PARAMS})
# mkdir spark-binary to cache spark
@@ -133,25 +104,27 @@ function build {
BUILD_ARGS+=(--build-arg spark_provided="spark_provided")
else
if [[ ! -d "$SPARK_HOME" ]]; then
- error "Cannot found dir $SPARK_HOME, you must configure SPARK_HOME correct."
+ if [[ -d "$KYUUBI_ROOT/externals/spark-*" ]]; then
+ SPARK_HOME="$(find "$KYUUBI_ROOT/externals" -name 'spark-*' -type d)"
+ else
+ error "Cannot found dir SPARK_HOME $SPARK_HOME, you must configure SPARK_HOME correct."
+ fi
fi
cp -r "$SPARK_HOME/" "$KYUUBI_ROOT/spark-binary/"
fi
# Verify that the Docker image content directory is present
if [ ! -d "$KYUUBI_ROOT/docker" ]; then
- error "Cannot find docker image. This script must be run from a runnable distribution of Apache Kyuubi."
+ error "Can't find Kyuubi docker context $KYUUBI_ROOT/docker, please check whether the binary package is complete."
fi
- # Verify that Kyuubi has actually been built/is a runnable distribution
- # i.e. the Kyuubi JARs that the Docker files will place into the image are present
+ # Verify that that Kyuubi need JARS is present
local TOTAL_JARS=$(ls $KYUUBI_ROOT/jars/kyuubi-* | wc -l)
TOTAL_JARS=$(( $TOTAL_JARS ))
if [ "${TOTAL_JARS}" -eq 0 ]; then
- error "Cannot find Kyuubi JARs. This script assumes that Apache Kyuubi has first been built locally or this is a runnable distribution."
+ error "Cannot find Kyuubi JARs. Please check whether the binary package is complete."
fi
- # If a custom Kyuubi_UID was set add it to build arguments
if [ -n "$KYUUBI_UID" ]; then
BUILD_ARGS+=(--build-arg kyuubi_uid=$KYUUBI_UID)
fi
@@ -160,20 +133,20 @@ function build {
local ARCHS=${ARCHS:-"--platform linux/amd64,linux/arm64"}
(cd $(img_ctx_dir base) && docker build $NOCACHEARG "${BUILD_ARGS[@]}" \
- -t $(image_ref kyuubi) \
+ -t $(image_ref $KYUUBI_IMAGE_NAME) \
-f "$BASEDOCKERFILE" .)
if [ $? -ne 0 ]; then
error "Failed to build Kyuubi JVM Docker image, please refer to Docker build output for details."
fi
if [ "${CROSS_BUILD}" != "false" ]; then
(cd $(img_ctx_dir base) && docker buildx build $ARCHS $NOCACHEARG "${BUILD_ARGS[@]}" --push \
- -t $(image_ref kyuubi) \
+ -t $(image_ref $KYUUBI_IMAGE_NAME) \
-f "$BASEDOCKERFILE" .)
fi
}
function push {
- docker_push "kyuubi"
+ docker_push $KYUUBI_IMAGE_NAME
}
function usage {