From 6ef7fa5d570d701f30ad3891d8d6c6df44884ca0 Mon Sep 17 00:00:00 2001 From: Ani Balasubramaniam Date: Tue, 2 Jun 2020 00:41:45 -0700 Subject: [PATCH 1/3] Autmagically use 1386/debian:buster when running on 64-bit host to prevent error #271 --- Dockerfile | 3 ++- build-docker.sh | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2e53149..3d5874d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,5 @@ -FROM debian:buster +ARG BASE_IMAGE=debian:buster +FROM ${BASE_IMAGE} ENV DEBIAN_FRONTEND noninteractive diff --git a/build-docker.sh b/build-docker.sh index b6a9ea3..6ab8f4c 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -73,7 +73,10 @@ fi # Modify original build-options to allow config file to be mounted in the docker container BUILD_OPTS="$(echo "${BUILD_OPTS:-}" | sed -E 's@\-c\s?([^ ]+)@-c /config@')" -${DOCKER} build -t pi-gen "${DIR}" +ARCH=$(uname -m) +[[ $ARCH == "x86_64" || $ARCH == "aarch64" ]] && BASE_IMAGE=i386/debian:buster || BASE_IMAGE=debian:buster +${DOCKER} build --build-arg BASE_IMAGE=${BASE_IMAGE} -t pi-gen "${DIR}" + if [ "${CONTAINER_EXISTS}" != "" ]; then trap 'echo "got CTRL+C... please wait 5s" && ${DOCKER} stop -t 5 ${CONTAINER_NAME}_cont' SIGINT SIGTERM time ${DOCKER} run --rm --privileged \ From c1d1015c9b08ca56c493f49f9399523f24f3023b Mon Sep 17 00:00:00 2001 From: Ani Balasubramaniam Date: Tue, 2 Jun 2020 00:47:37 -0700 Subject: [PATCH 2/3] Add comment --- build-docker.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/build-docker.sh b/build-docker.sh index 6ab8f4c..7ba3194 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -73,6 +73,7 @@ fi # Modify original build-options to allow config file to be mounted in the docker container BUILD_OPTS="$(echo "${BUILD_OPTS:-}" | sed -E 's@\-c\s?([^ ]+)@-c /config@')" +# Check the arch of the machine we're running on. If it's 64-bit, use a 32-bit base image instead ARCH=$(uname -m) [[ $ARCH == "x86_64" || $ARCH == "aarch64" ]] && BASE_IMAGE=i386/debian:buster || BASE_IMAGE=debian:buster ${DOCKER} build --build-arg BASE_IMAGE=${BASE_IMAGE} -t pi-gen "${DIR}" From 4f5dfc4d1e4c1ccd25d015ebad4e43fc4c414385 Mon Sep 17 00:00:00 2001 From: Ani Balasubramaniam Date: Tue, 2 Jun 2020 08:58:25 -0700 Subject: [PATCH 3/3] Fix conditional to read better using a case statement --- build-docker.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/build-docker.sh b/build-docker.sh index 7ba3194..350f722 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -74,8 +74,14 @@ fi BUILD_OPTS="$(echo "${BUILD_OPTS:-}" | sed -E 's@\-c\s?([^ ]+)@-c /config@')" # Check the arch of the machine we're running on. If it's 64-bit, use a 32-bit base image instead -ARCH=$(uname -m) -[[ $ARCH == "x86_64" || $ARCH == "aarch64" ]] && BASE_IMAGE=i386/debian:buster || BASE_IMAGE=debian:buster +case "$(uname -m)" in + x86_64|aarch64) + BASE_IMAGE=i386/debian:buster + ;; + *) + BASE_IMAGE=debian:buster + ;; +esac ${DOCKER} build --build-arg BASE_IMAGE=${BASE_IMAGE} -t pi-gen "${DIR}" if [ "${CONTAINER_EXISTS}" != "" ]; then