Skip to content

Commit 0a5d607

Browse files
committed
[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.
1 parent f92d276 commit 0a5d607

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

bin/docker-image-tool.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ function docker_push {
6767
fi
6868
}
6969

70+
function resolve_file {
71+
local FILE=$1
72+
if [ -n "$FILE" ]; then
73+
local DIR=$(dirname $FILE)
74+
DIR=$(cd $DIR && pwd)
75+
FILE="${DIR}/$(basename $FILE)"
76+
fi
77+
echo $FILE
78+
}
79+
7080
# Create a smaller build context for docker in dev builds to make the build faster. Docker
7181
# uploads all of the current directory to the daemon, and it can get pretty big with dev
7282
# builds that contain test log files and other artifacts.
@@ -257,9 +267,9 @@ while getopts f:p:R:mr:t:nb:u: option
257267
do
258268
case "${option}"
259269
in
260-
f) BASEDOCKERFILE=${OPTARG};;
261-
p) PYDOCKERFILE=${OPTARG};;
262-
R) RDOCKERFILE=${OPTARG};;
270+
f) BASEDOCKERFILE=$(resolve_file ${OPTARG});;
271+
p) PYDOCKERFILE=$(resolve_file ${OPTARG});;
272+
R) RDOCKERFILE=$(resolve_file ${OPTARG});;
263273
r) REPO=${OPTARG};;
264274
t) TAG=${OPTARG};;
265275
n) NOCACHEARG="--no-cache";;

0 commit comments

Comments
 (0)