mirror of
https://github.com/signalapp/libsignal.git
synced 2024-09-20 03:52:17 +02:00
Docker: Use -it and --init to handle SIGTERM (^C) properly
-i (interactive) and -t (allocate a tty) allow the shell running inside Docker to handle Ctrl-C (^C) and other shell commands, so you can stop a command in the interactive process you ran it. However, they only work if the containing shell (the one where you ran `docker run`) is also interactive with a tty hooked up, so we test for that first in both scripts that invoke `docker run`, using `test -t`. --init passes signals from *outside* Docker down to its subprocesses, so that cancellation from *another* context works for our Docker images. This includes the Cancel button in GitHub Actions.
This commit is contained in:
parent
cbe7b8a86c
commit
d270e06127
@ -10,18 +10,19 @@ DOCKER ?= docker
|
||||
default: java_build
|
||||
|
||||
DOCKER_IMAGE := libsignal-builder
|
||||
DOCKER_TTY_FLAG := $$(test -t 0 && echo -it)
|
||||
|
||||
docker_image:
|
||||
cd .. && $(DOCKER) build --build-arg UID=$$(id -u) --build-arg GID=$$(id -g) -t $(DOCKER_IMAGE) -f java/Dockerfile .
|
||||
|
||||
java_build: DOCKER_EXTRA=$(shell [ -L build ] && P=$$(readlink build) && echo -v $$P/:$$P )
|
||||
java_build: docker_image
|
||||
$(DOCKER) run --rm --user $$(id -u):$$(id -g) \
|
||||
$(DOCKER) run $(DOCKER_TTY_FLAG) --init --rm --user $$(id -u):$$(id -g) \
|
||||
-v `cd .. && pwd`/:/home/libsignal/src $(DOCKER_EXTRA) $(DOCKER_IMAGE) \
|
||||
sh -c "cd src/java; ./gradlew build"
|
||||
|
||||
java_test: java_build
|
||||
$(DOCKER) run --rm --user $$(id -u):$$(id -g) \
|
||||
$(DOCKER) run $(DOCKER_TTY_FLAG) --init --rm --user $$(id -u):$$(id -g) \
|
||||
-v `cd .. && pwd`/:/home/libsignal/src $(DOCKER_EXTRA) $(DOCKER_IMAGE) \
|
||||
sh -c "cd src/java; ./gradlew test"
|
||||
|
||||
|
@ -13,11 +13,16 @@ cd "${SCRIPT_DIR}"/..
|
||||
|
||||
DOCKER_IMAGE=libsignal-node-builder
|
||||
|
||||
IS_TTY=""
|
||||
if [[ -t 0 ]]; then
|
||||
IS_TTY="yes"
|
||||
fi
|
||||
|
||||
docker build --build-arg "UID=${UID:-501}" --build-arg "GID=${GID:-501}" -t ${DOCKER_IMAGE} -f node/Dockerfile .
|
||||
|
||||
# We build both architectures in the same run action to save on intermediates
|
||||
# (including downloading dependencies)
|
||||
docker run --rm -v "${PWD}":/home/libsignal/src ${DOCKER_IMAGE} sh -c '
|
||||
docker run ${IS_TTY:+ -it} --init --rm -v "${PWD}":/home/libsignal/src ${DOCKER_IMAGE} sh -c '
|
||||
cd ~/src/node &&
|
||||
env CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
|
||||
CC=aarch64-linux-gnu-gcc \
|
||||
|
Loading…
Reference in New Issue
Block a user