diff --git a/Makefile b/Makefile index 531563e..64e2003 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,7 @@ endif ETC_LOCALTIME := $(realpath /etc/localtime) -HOST_ARCH := $(shell arch) +HOST_ARCH ?= $(shell arch) ifeq ($(HOST_ARCH),x86_64) DOCKER_PLATFORM := "linux/amd64" else ifeq ($(HOST_ARCH),arm64) diff --git a/build.sh b/build.sh index acacb44..9c606bd 100755 --- a/build.sh +++ b/build.sh @@ -36,15 +36,8 @@ DOCKER_BUILD="docker build" DOCKER_INSPECT="docker inspect" DOCKER_FLAGS="--force-rm=true" -HOST_ARCH=`arch` -if [[ $HOST_ARCH == "x86_64" ]]; then - DOCKER_PLATFORM="linux/amd64" -elif [[ $HOST_ARCH == "arm64" ]]; then - DOCKER_PLATFORM="linux/arm64/v8" -else - echo "Unsupported host architecture: $HOST_ARCH" - exit 1 -fi +# By default use host architecture +: "${HOST_ARCH:=`arch`}" # Special variables to be passed through Docker to the build scripts : "${SCM}" @@ -182,7 +175,7 @@ show_help() | sort \ | tr "\n" "|") cat <&2 exit 1 ;; esac done +if [[ $HOST_ARCH == "x86_64" ]]; then + DOCKER_PLATFORM="linux/amd64" +elif [[ $HOST_ARCH == "amd64" ]]; then + DOCKER_PLATFORM="linux/amd64" +elif [[ $HOST_ARCH == "arm64" ]]; then + DOCKER_PLATFORM="linux/arm64/v8" +else + echo "Unsupported host architecture: $HOST_ARCH" + exit 1 +fi + +echo "Building for $DOCKER_PLATFORM" + if [ -z "$img_to_build" ] then echo "You need to supply a \`-b\`" >&2