zwangsheng commented on a change in pull request #1435:
URL: https://github.com/apache/incubator-kyuubi/pull/1435#discussion_r755793203



##########
File path: bin/docker-image-tool.sh
##########
@@ -0,0 +1,281 @@
+#!/usr/bin/env bash
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# This script builds and pushes docker images when run from a release of Kyuubi
+# with Kubernetes support.
+
+function error {
+  echo "$@" 1>&2
+  exit 1
+}
+
+if [ -z "${KYUUBI_HOME}" ]; then
+  KYUUBI_HOME="$(cd "`dirname "$0"`"/..; pwd)"
+fi
+
+CTX_DIR="$KYUUBI_HOME/target/tmp/docker"
+
+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
+
+# trap cleanup_ctx_dir EXIT
+
+function image_ref {
+  local image="$1"
+  local add_repo="${2:-1}"
+  if [ $add_repo = 1 ] && [ -n "$REPO" ]; then
+    image="$REPO/$image"
+  fi
+  if [ -n "$TAG" ]; then
+    image="$image:$TAG"
+  fi
+  echo "$image:$KYUUBI_VERSION"
+}
+
+function docker_push {
+  local image_name="$1"
+  if [ ! -z $(docker images -q "$(image_ref ${image_name})") ]; then
+    docker push "$(image_ref ${image_name})"
+    if [ $? -ne 0 ]; then
+      error "Failed to push $image_name Docker image."
+    fi
+  else
+    echo "$(image_ref ${image_name}) image not found. Skipping push for this 
image."
+  fi
+}
+
+function resolve_file {
+  local FILE=$1
+  if [ -n "$FILE" ]; then
+    local DIR=$(dirname $FILE)
+    DIR=$(cd $DIR && pwd)
+    FILE="${DIR}/$(basename $FILE)"
+  fi
+  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 -r "$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
+}
+
+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
+
+  # cp spark for kyuubi as submit client
+  # if user set -s(spark-provider), use if
+  # else use builtin spark
+  if [[ ! -d "$KYUUBI_ROOT/spark" ]]; then
+    mkdir "$KYUUBI_ROOT/spark"
+  fi
+  if [[ -n "$SPARK_BUILDIN" ]] && [[ -d "$SPARK_BUILDIN" ]]; then
+    cp -r "$SPARK_BUILDIN/" "$KYUUBI_ROOT/spark/"
+  else
+    cp -r 
"${KYUUBI_HOME}/externals/kyuubi-download/target/spark-$SPARK_VERSION_BUILD-bin-hadoop${HADOOP_VERSION_BUILD}/"
 "$KYUUBI_ROOT/spark/"
+  fi

Review comment:
       Copy `Spark` here, please have a check.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to