diff --git a/core/files_artifacts_expander/scripts/build.sh b/core/files_artifacts_expander/scripts/build.sh index ba8bfedc10..7f18864805 100755 --- a/core/files_artifacts_expander/scripts/build.sh +++ b/core/files_artifacts_expander/scripts/build.sh @@ -7,6 +7,7 @@ set -euo pipefail # Bash "strict mode" script_dirpath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" expander_root_dirpath="$(dirname "${script_dirpath}")" git_repo_dirpath="$(dirname "$(dirname "${expander_root_dirpath}")")" +uname_arch=$(uname -m) # ================================================================================================== # Constants # ================================================================================================== @@ -15,7 +16,14 @@ source "${script_dirpath}/_constants.env" BUILD_DIRNAME="build" DEFAULT_SKIP_DOCKER_IMAGE_BUILDING=false -DEFAULT_ARCHITECTURE_TO_BUILD=amd64 + +DEFAULT_ARCHITECTURE_TO_BUILD="unknown" + +if [ "$uname_arch" == "x86_64" ] || [ "$uname_arch" == "amd64" ]; then + DEFAULT_ARCHITECTURE_TO_BUILD="amd64" +elif [ "$uname_arch" == "aarch64" ] || [ "$uname_arch" == "arm64" ]; then + DEFAULT_ARCHITECTURE_TO_BUILD="arm64" +fi MAIN_GO_FILEPATH="${expander_root_dirpath}/main.go" MAIN_BINARY_OUTPUT_FILENAME="files-artifacts-expander" diff --git a/core/server/scripts/build.sh b/core/server/scripts/build.sh index 4c85ba2f0e..0930255de5 100755 --- a/core/server/scripts/build.sh +++ b/core/server/scripts/build.sh @@ -5,6 +5,7 @@ set -euo pipefail # Bash "strict mode" script_dirpath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" server_root_dirpath="$(dirname "${script_dirpath}")" git_repo_dirpath="$(dirname "$(dirname "${server_root_dirpath}")")" +uname_arch=$(uname -m) # ================================================================================================== # Constants # ================================================================================================== @@ -13,7 +14,14 @@ source "${script_dirpath}/_constants.env" BUILD_DIRNAME="build" DEFAULT_SKIP_DOCKER_IMAGE_BUILDING=false -DEFAULT_ARCHITECTURE_TO_BUILD=amd64 + +DEFAULT_ARCHITECTURE_TO_BUILD="unknown" + +if [ "$uname_arch" == "x86_64" ] || [ "$uname_arch" == "amd64" ]; then + DEFAULT_ARCHITECTURE_TO_BUILD="amd64" +elif [ "$uname_arch" == "aarch64" ] || [ "$uname_arch" == "arm64" ]; then + DEFAULT_ARCHITECTURE_TO_BUILD="arm64" +fi MAIN_DIRNAME="api_container" MAIN_GO_FILEPATH="${server_root_dirpath}/${MAIN_DIRNAME}/main.go" diff --git a/engine/server/scripts/build.sh b/engine/server/scripts/build.sh index b4b0ee5e6d..05655c1c4f 100755 --- a/engine/server/scripts/build.sh +++ b/engine/server/scripts/build.sh @@ -5,7 +5,7 @@ set -euo pipefail # Bash "strict mode" script_dirpath="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" engine_root_dirpath="$(dirname "${script_dirpath}")" git_repo_dirpath="$(dirname "$(dirname "${engine_root_dirpath}")")" - +uname_arch=$(uname -m) # ================================================================================================== # Constants # ================================================================================================== @@ -14,7 +14,14 @@ source "${script_dirpath}/_constants.env" BUILD_DIRNAME="build" DEFAULT_SKIP_DOCKER_IMAGE_BUILDING=false -DEFAULT_ARCHITECTURE_TO_BUILD=amd64 + +DEFAULT_ARCHITECTURE_TO_BUILD="unknown" + +if [ "$uname_arch" == "x86_64" ] || [ "$uname_arch" == "amd64" ]; then + DEFAULT_ARCHITECTURE_TO_BUILD="amd64" +elif [ "$uname_arch" == "aarch64" ] || [ "$uname_arch" == "arm64" ]; then + DEFAULT_ARCHITECTURE_TO_BUILD="arm64" +fi MAIN_DIRNAME="engine" MAIN_GO_FILEPATH="${engine_root_dirpath}/${MAIN_DIRNAME}/main.go" diff --git a/scripts/docker-image-builder.sh b/scripts/docker-image-builder.sh index dffcd64f56..7c470f322f 100755 --- a/scripts/docker-image-builder.sh +++ b/scripts/docker-image-builder.sh @@ -36,12 +36,22 @@ if [ -z "${image_tags}" ]; then show_helptext_and_exit fi +uname_arch=$(uname -m) + +architecture="amd64" + +if [ "$uname_arch" == "x86_64" ] || [ "$uname_arch" == "amd64" ]; then + architecture="amd64" +elif [ "$uname_arch" == "aarch64" ] || [ "$uname_arch" == "arm64" ]; then + architecture="arm64" +fi + # Argument processing if "${push_to_registry_container}"; then buildx_platform_arg='linux/arm64/v8,linux/amd64' push_flag='--push' else - buildx_platform_arg='linux/amd64' # TODO: infer the local arch if that's reasonable + buildx_platform_arg="linux/${architecture}" push_flag='--load' fi echo "Building docker image for architecture '${buildx_platform_arg}' with flag '${push_flag}'"