Skip to content

Commit 15524c4

Browse files
author
Marcelo Vanzin
committed
[SPARK-25682][K8S] Package example jars in same target for dev and distro images.
This way the image generated from both environments has the same layout, with just a difference in contents that should not affect functionality. Also added some minor error checking to the image script. Closes #22681 from vanzin/SPARK-25682. Authored-by: Marcelo Vanzin <[email protected]> Signed-off-by: Marcelo Vanzin <[email protected]>
1 parent e80f18d commit 15524c4

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

bin/docker-image-tool.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ function build {
4747

4848
if [ ! -f "$SPARK_HOME/RELEASE" ]; then
4949
# Set image build arguments accordingly if this is a source repo and not a distribution archive.
50+
#
51+
# Note that this will copy all of the example jars directory into the image, and that will
52+
# contain a lot of duplicated jars with the main Spark directory. In a proper distribution,
53+
# the examples directory is cleaned up before generating the distribution tarball, so this
54+
# issue does not occur.
5055
IMG_PATH=resource-managers/kubernetes/docker/src/main/dockerfiles
5156
BUILD_ARGS=(
5257
${BUILD_PARAMS}
@@ -55,6 +60,8 @@ function build {
5560
--build-arg
5661
spark_jars=assembly/target/scala-$SPARK_SCALA_VERSION/jars
5762
--build-arg
63+
example_jars=examples/target/scala-$SPARK_SCALA_VERSION/jars
64+
--build-arg
5865
k8s_tests=resource-managers/kubernetes/integration-tests/tests
5966
)
6067
else
@@ -78,14 +85,23 @@ function build {
7885
docker build $NOCACHEARG "${BUILD_ARGS[@]}" \
7986
-t $(image_ref spark) \
8087
-f "$BASEDOCKERFILE" .
88+
if [[ $? != 0 ]]; then
89+
error "Failed to build Spark docker image."
90+
fi
8191

8292
docker build $NOCACHEARG "${BINDING_BUILD_ARGS[@]}" \
8393
-t $(image_ref spark-py) \
8494
-f "$PYDOCKERFILE" .
95+
if [[ $? != 0 ]]; then
96+
error "Failed to build PySpark docker image."
97+
fi
8598

8699
docker build $NOCACHEARG "${BINDING_BUILD_ARGS[@]}" \
87100
-t $(image_ref spark-r) \
88101
-f "$RDOCKERFILE" .
102+
if [[ $? != 0 ]]; then
103+
error "Failed to build SparkR docker image."
104+
fi
89105
}
90106

91107
function push {

resource-managers/kubernetes/docker/src/main/dockerfiles/spark/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
FROM openjdk:8-alpine
1919

2020
ARG spark_jars=jars
21+
ARG example_jars=examples/jars
2122
ARG img_path=kubernetes/dockerfiles
2223
ARG k8s_tests=kubernetes/tests
2324

@@ -32,6 +33,7 @@ RUN set -ex && \
3233
apk upgrade --no-cache && \
3334
apk add --no-cache bash tini libc6-compat linux-pam krb5 krb5-libs && \
3435
mkdir -p /opt/spark && \
36+
mkdir -p /opt/spark/examples && \
3537
mkdir -p /opt/spark/work-dir && \
3638
touch /opt/spark/RELEASE && \
3739
rm /bin/sh && \
@@ -43,7 +45,8 @@ COPY ${spark_jars} /opt/spark/jars
4345
COPY bin /opt/spark/bin
4446
COPY sbin /opt/spark/sbin
4547
COPY ${img_path}/spark/entrypoint.sh /opt/
46-
COPY examples /opt/spark/examples
48+
COPY ${example_jars} /opt/spark/examples/jars
49+
COPY examples/src /opt/spark/examples/src
4750
COPY ${k8s_tests} /opt/spark/tests
4851
COPY data /opt/spark/data
4952

0 commit comments

Comments
 (0)