From 0a5d607da63373e07055d6b5fc7cf6681a93b188 Mon Sep 17 00:00:00 2001 From: Rob Vesse Date: Tue, 22 Jan 2019 11:13:38 +0000 Subject: [PATCH] [SPARK-26687][K8S] Fix handling of custom Dockerfile paths Fixes a bug with bin/docker-image-tool.sh not resolving relative paths to custom Dockerfiles which results in docker builds failing with unhelpful errors because the builds are run from inside the temporary build context directory. Therefore valid relative paths where the script are invoked becomes invalid when the actual docker build is attempted. --- bin/docker-image-tool.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bin/docker-image-tool.sh b/bin/docker-image-tool.sh index 4f66137eb1c7a..e1f5a5c654b82 100755 --- a/bin/docker-image-tool.sh +++ b/bin/docker-image-tool.sh @@ -67,6 +67,16 @@ function docker_push { 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. @@ -257,9 +267,9 @@ while getopts f:p:R:mr:t:nb:u: option do case "${option}" in - f) BASEDOCKERFILE=${OPTARG};; - p) PYDOCKERFILE=${OPTARG};; - R) RDOCKERFILE=${OPTARG};; + f) BASEDOCKERFILE=$(resolve_file ${OPTARG});; + p) PYDOCKERFILE=$(resolve_file ${OPTARG});; + R) RDOCKERFILE=$(resolve_file ${OPTARG});; r) REPO=${OPTARG};; t) TAG=${OPTARG};; n) NOCACHEARG="--no-cache";;