In cases where we are running non-interactively (e.g. on Jenkins), we
shouldn't try to allocate a TTY, which would fail. This patch makes the
flag `-t` be dependent on whether the shell session is interactive or
not.
When it is interactive, it's important to have `-t` so that the user can
pass signals through to the process.
We also remove the DOCKER_RUN_DOCS and the GITCOMMIT variables, which
are no longer in use in this Makefile (seems like the related targets
that used it were migrated to docs/Makefile).
Signed-off-by: Jonathan Lebon <jlebon@redhat.com>
| ... | ... |
@@ -29,12 +29,17 @@ GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) |
| 29 | 29 |
DOCKER_IMAGE := docker-dev$(if $(GIT_BRANCH),:$(GIT_BRANCH)) |
| 30 | 30 |
DOCKER_DOCS_IMAGE := docker-docs$(if $(GIT_BRANCH),:$(GIT_BRANCH)) |
| 31 | 31 |
|
| 32 |
-DOCKER_RUN_DOCKER := docker run --rm -it --privileged $(DOCKER_ENVS) $(DOCKER_MOUNT) "$(DOCKER_IMAGE)" |
|
| 32 |
+DOCKER_FLAGS := docker run --rm -i --privileged $(DOCKER_ENVS) $(DOCKER_MOUNT) |
|
| 33 | 33 |
|
| 34 |
-DOCKER_RUN_DOCS := docker run --rm -it $(DOCS_MOUNT) -e AWS_S3_BUCKET -e NOCACHE |
|
| 34 |
+# if this session isn't interactive, then we don't want to allocate a |
|
| 35 |
+# TTY, which would fail, but if it is interactive, we do want to attach |
|
| 36 |
+# so that the user can send e.g. ^C through. |
|
| 37 |
+INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0) |
|
| 38 |
+ifeq ($(INTERACTIVE), 1) |
|
| 39 |
+ DOCKER_FLAGS += -t |
|
| 40 |
+endif |
|
| 35 | 41 |
|
| 36 |
-# for some docs workarounds (see below in "docs-build" target) |
|
| 37 |
-GITCOMMIT := $(shell git rev-parse --short HEAD 2>/dev/null) |
|
| 42 |
+DOCKER_RUN_DOCKER := $(DOCKER_FLAGS) "$(DOCKER_IMAGE)" |
|
| 38 | 43 |
|
| 39 | 44 |
default: binary |
| 40 | 45 |
|