From 4fd20bdb87ffa8ca9db7c361fded9d9b3c5953b6 Mon Sep 17 00:00:00 2001 From: Hugo Hromic Date: Mon, 29 Jul 2019 20:55:43 +0100 Subject: [PATCH] Ensure that the configuration file is an absolute path in Docker build The specific problem is in commit 2ddd7c1, where the passed config file (using the `-c` option) is now mounted inside the container using the `--volume src:dest:opt` Docker option. The problem is that Docker requires absolute paths for mounting single files inside the container, otherwise it silently tries to mount a volume name instead as an empty directory. Therefore the Docker build no longer works with the following invocation forms (relative config-paths): ./build-docker.sh -c myconfig /path/to/build-docker.sh -c myconfig # also doesn't work This commit uses `realpath` (included in coreutils) in the Docker build script to ensure that the passed configuration file is always an absolute path before passing it to Docker. --- build-docker.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/build-docker.sh b/build-docker.sh index fec7cc6..3d7634d 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -30,6 +30,9 @@ do esac done +# Ensure that the configuration file is an absolute path +CONFIG_FILE=$(realpath -s "$CONFIG_FILE") + # Ensure that the confguration file is present if test -z "${CONFIG_FILE}"; then echo "Configuration file need to be present in '${DIR}/config' or path passed as parameter"