From b70b851321ca459047b614d01246b124ecd2cf69 Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Wed, 4 Nov 2020 21:17:50 -0800 Subject: [PATCH] Teach docker-run to run interactively or to be able to run from a non-interactive process like a git hook Fixes #959 --- bin/run-docker | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/run-docker b/bin/run-docker index 3f7e1bb0..6e9d0051 100755 --- a/bin/run-docker +++ b/bin/run-docker @@ -4,6 +4,14 @@ set -e uname_S=$(uname -s 2>/dev/null || echo not) +# If we're running in a terminal and want interactive docker +# Specifically "is there a STDIN file descriptor" +if [ -t 0 ]; then + : "${DOCKER_RUN_INTERACTIVE_OPTS:=--tty --interactive}" +fi + + + if [ "${uname_S}" = "Darwin" ]; then ARDUINO_LOCAL_LIB_PATH="${ARDUINO_LOCAL_LIB_PATH:-${HOME}/Documents/Arduino}" # This stops macos from copying resource forks into thigns like tar @@ -28,7 +36,8 @@ tar -cf "${XFER_DIR}/kaleidoscope.tar" \ echo "Building the docker image..." docker build -q -t kaleidoscope/docker etc -docker run --rm -it \ +# shellcheck disable=SC2086 # We do want word splitting since there are multiple options here +docker run --rm $DOCKER_RUN_INTERACTIVE_OPTS \ --tmpfs /kaleidoscope:exec \ --mount type=bind,source="${XFER_DIR}",destination=/kaleidoscope-src,consistency=delegated,readonly \ --mount type=volume,source=kaleidoscope-persist,destination=/kaleidoscope-persist,consistency=delegated \