Skip to content

Commit

Permalink
ensure real paths are used for volume mounts (needed in particular by…
Browse files Browse the repository at this point in the history
… OSX as they must be exported by docker for mac)
  • Loading branch information
gautaz committed Nov 13, 2016
1 parent a1b0cc1 commit 26c760d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions dnpm
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,19 @@ if [ -z "${WORKDIR}" ]; then
exit 1
fi

function clean() {
# realpath is not always available
realpath() {
local rpath="$(cd -P -- "$(dirname -- "$1")" && pwd -P)/$(basename -- "$1")"

while [[ -h "${rapth}" ]]; do
local link=$(readlink "${rpath}")
rpath=$(cd "$(dirname -- "${rpath}")" && cd "$(dirname -- "${link}")" && pwd)/$(basename -- "${link}")
done

echo "${rpath}"
}

clean() {
rm -f "${ENTRYPOINT}"
}
ENTRYPOINT="$(mktemp)"
Expand Down Expand Up @@ -113,9 +125,9 @@ chown -R "\$(stat -c "%u:%g" /work)" /work
EOS

docker run --rm --privileged \
-v "${HOME}:${HOMEDIR}:ro" \
-v "${WORKDIR}:/work" \
-v "${ENTRYPOINT}:/entrypoint" \
-v "$(realpath "${HOME}"):${HOMEDIR}:ro" \
-v "$(realpath "${WORKDIR}"):/work" \
-v "$(realpath "${ENTRYPOINT}"):/entrypoint" \
${SSHVOLUME:+-v "${SSHVOLUME}:/ssh" -e SSH_AUTH_SOCK=/ssh/auth/sock} \
$(env | grep -i "^npm_config_" | awk -F'=' '{ printf "-e " $1 "=\"" $2 "\" " }') \
-e XDG_CONFIG_HOME=/tmp/xdg-config \
Expand Down

0 comments on commit 26c760d

Please sign in to comment.