diff --git a/build.sh b/build.sh index 6ec1cce..050fddb 100755 --- a/build.sh +++ b/build.sh @@ -5,8 +5,15 @@ set -e -x DIR=$(cd "$(dirname "$0")"; pwd -P) TOOLCHAIN_IMAGE="esp32-toolchain:latest" -BUILD_DIR="$DIR/cmake-build" +: ${BUILD_DIR:="$DIR/cmake-build"} DOCKERFILE="$DIR/Dockerfile" +DOCKER_RUN_FLAGS=(--interactive --rm) + +# if stdin is a terminal, tell docker to allocate a tty +if [ -t 0 ]; then + DOCKER_RUN_FLAGS+=(--tty) +fi + build_docker_container() { docker build -f "$DOCKERFILE" -t "$TOOLCHAIN_IMAGE" "$DIR" @@ -16,7 +23,7 @@ build_docker() { build_docker_container docker run \ --volume="$DIR:/esp/uas-ugv" \ - --interactive --tty --rm \ + "${DOCKER_RUN_FLAGS[@]}" \ "$TOOLCHAIN_IMAGE" \ /esp/uas-ugv/build.sh cmake "$@" }