From 2e6726e10de61904e90a80ddefcc0b677d448904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrich=20Kr=C3=A4mer?= Date: Thu, 30 Dec 2021 14:16:19 +0100 Subject: [PATCH 1/2] build-and-push-images use linux/amd64 for typescript --- Makefile | 11 ++++++++++- scripts/build-and-push-images.sh | 13 ++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 41ef175d..89e8c950 100644 --- a/Makefile +++ b/Makefile @@ -104,7 +104,16 @@ install-tekton-pipelines: ## Install Tekton pipelines in KinD cluster. .PHONY: install-tekton-pipelines build-and-push-images: ## Build and push images to local registry. - cd scripts && ./build-and-push-images.sh + cd scripts && ./build-and-push-images.sh --image start + cd scripts && ./build-and-push-images.sh --image finish + cd scripts && ./build-and-push-images.sh --image buildah + cd scripts && ./build-and-push-images.sh --image sonar + cd scripts && ./build-and-push-images.sh --image webhook-interceptor + cd scripts && ./build-and-push-images.sh --image go-toolset + cd scripts && ./build-and-push-images.sh --image gradle-toolset + cd scripts && ./build-and-push-images.sh --image python-toolset + cd scripts && ./build-and-push-images.sh --image helm + cd scripts && ./build-and-push-images.sh --image node16-typescript-toolset --platform linux/amd64 .PHONY: build-and-push-images install-ods-tasks-kind: ## KinD only! Apply ODS ClusterTask manifests in KinD diff --git a/scripts/build-and-push-images.sh b/scripts/build-and-push-images.sh index a669369f..0ed2cab5 100755 --- a/scripts/build-and-push-images.sh +++ b/scripts/build-and-push-images.sh @@ -14,6 +14,9 @@ IMAGES="" http_proxy="${http_proxy:-}" https_proxy="${https_proxy:-}" +PLATFORM="" +# eg. --platform linux/amd64 + while [[ "$#" -gt 0 ]]; do case $1 in @@ -24,6 +27,9 @@ while [[ "$#" -gt 0 ]]; do -i|--image) IMAGES="$2"; shift;; -i=*|--image=*) IMAGES="${1#*=}";; + -i|--platform) PLATFORM="$2"; shift;; + -i=*|--platform=*) PLATFORM="${1#*=}";; + *) echo "Unknown parameter passed: $1"; exit 1;; esac; shift; done @@ -33,7 +39,7 @@ build_and_push_image() { odsImage="ods-$image" if [ "${SKIP_BUILD}" != "true" ]; then echo "Building image $REGISTRY/$NAMESPACE/$odsImage..." - docker build \ + docker build $platform_arg \ --build-arg http_proxy="$http_proxy" \ --build-arg https_proxy="$https_proxy" \ --build-arg HTTP_PROXY="$http_proxy" \ @@ -44,6 +50,11 @@ build_and_push_image() { docker push "$REGISTRY/$NAMESPACE/$odsImage" } +platform_arg="" +if [ ! -z "$PLATFORM" ]; then + platform_arg="--platform $PLATFORM" +fi + if [ -z "$IMAGES" ]; then for file in build/package/Dockerfile.*; do image=${file##*Dockerfile.} From 611b19620137d9078afeba69fb2e80dc11d7025d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrich=20Kr=C3=A4mer?= Date: Wed, 12 Jan 2022 09:38:27 +0100 Subject: [PATCH 2/2] shellcheck changes and exception --- scripts/build-and-push-images.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/build-and-push-images.sh b/scripts/build-and-push-images.sh index 0ed2cab5..d7a8a5b7 100755 --- a/scripts/build-and-push-images.sh +++ b/scripts/build-and-push-images.sh @@ -27,8 +27,8 @@ while [[ "$#" -gt 0 ]]; do -i|--image) IMAGES="$2"; shift;; -i=*|--image=*) IMAGES="${1#*=}";; - -i|--platform) PLATFORM="$2"; shift;; - -i=*|--platform=*) PLATFORM="${1#*=}";; + -p|--platform) PLATFORM="$2"; shift;; + -p=*|--platform=*) PLATFORM="${1#*=}";; *) echo "Unknown parameter passed: $1"; exit 1;; esac; shift; done @@ -39,6 +39,7 @@ build_and_push_image() { odsImage="ods-$image" if [ "${SKIP_BUILD}" != "true" ]; then echo "Building image $REGISTRY/$NAMESPACE/$odsImage..." + # shellcheck disable=SC2086 docker build $platform_arg \ --build-arg http_proxy="$http_proxy" \ --build-arg https_proxy="$https_proxy" \ @@ -50,9 +51,9 @@ build_and_push_image() { docker push "$REGISTRY/$NAMESPACE/$odsImage" } -platform_arg="" -if [ ! -z "$PLATFORM" ]; then - platform_arg="--platform $PLATFORM" +platform_arg= +if [ -n "$PLATFORM" ]; then + platform_arg="--platform=${PLATFORM}" fi if [ -z "$IMAGES" ]; then