Github user liyinan926 commented on a diff in the pull request:
https://github.com/apache/spark/pull/20192#discussion_r160322848
--- Diff: bin/docker-image-tool.sh ---
@@ -60,35 +42,53 @@ function image_ref {
}
function build {
- docker build \
- --build-arg "spark_jars=$SPARK_JARS" \
- --build-arg "img_path=$IMG_PATH" \
- -t spark-base \
- -f "$IMG_PATH/spark-base/Dockerfile" .
- for image in "${!path[@]}"; do
- docker build -t "$(image_ref $image)" -f ${path[$image]} .
- done
+ # Detect whether this is a git clone or a Spark distribution and adjust
paths
+ # accordingly.
+ local BUILD_ARGS
+ local IMG_PATH
+
+ if [ ! -f "$SPARK_HOME/RELEASE" ]; then
+ IMG_PATH=resource-managers/kubernetes/docker/src/main/dockerfiles
+ BUILD_ARGS=(
+ --build-arg
+ img_path=$IMG_PATH
+ --build-arg
+ spark_jars=assembly/target/scala-$SPARK_SCALA_VERSION/jars
+ )
+ else
+ # Not passed as an argument to docker, but used to validate the Spark
directory.
+ IMG_PATH="kubernetes/dockerfiles"
+ fi
+
+ local DOCKERFILE=${DOCKERFILE:-"$IMG_PATH/spark/Dockerfile"}
+
+ if [ ! -d "$IMG_PATH" ]; then
+ error "Cannot find docker images. This script must be run from a
runnable distribution of Apache Spark."
+ fi
+
+ docker build "${BUILD_ARGS[@]}" \
+ -t $(image_ref spark) \
+ -f "$DOCKERFILE" .
}
function push {
- for image in "${!path[@]}"; do
- docker push "$(image_ref $image)"
- done
+ docker push "$(image_ref spark)"
}
function usage {
cat <<EOF
Usage: $0 [options] [command]
-Builds or pushes the built-in Spark Docker images.
+Builds or pushes the built-in Spark Docker image.
Commands:
- build Build images.
- push Push images to a registry. Requires a repository address to
be provided, both
- when building and when pushing the images.
+ build Build image.
+ push Push a pre-built image to a registry. Requires a repository
address to be provided,
+ both when building and when pushing the image.
--- End diff --
It's better to state explicitly for `build` and `push` individually.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]