@@ -3,7 +3,6 @@ CAT_CMD=$(if $(filter $(OS),Windows_NT),type,cat)
33RELEASE_VER: =
44CURRENT_DIR =$(shell pwd)
55GIT_BRANCH: =$(shell git symbolic-ref --short HEAD 2>&1 | grep -v fatal)
6-
76# define the GO_BUILD_ARGS if you need to pass additional arguments to the go build
87GO_BUILD_ARGS? =
98
@@ -137,16 +136,26 @@ manifests: controller-gen ## Generate CustomResourceDefinition objects.
137136generate-code : controller-gen # # Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
138137 $(CONTROLLER_GEN ) object:headerFile=" hack/boilerplate/boilerplate.go.txt" paths=" ./pkg/apis/..."
139138
139+ # Build the docker image and tag it.
140140images : verify-tag-name generate-code update-deployment-crds
141141 $(info List executable directory)
142142 $(info repo id: ${git_repository_id})
143143 $(info branch: ${GIT_BRANCH})
144144 $(info Build the docker image)
145- ifeq ($(strip $(GO_BUILD_ARGS ) ) ,)
146- docker build --quiet --no-cache --tag mcad-controller:${TAG} -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}
147- else
148- docker build --no-cache --tag mcad-controller:${TAG} --build-arg GO_BUILD_ARGS=$(GO_BUILD_ARGS) -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}
149- endif
145+ @HOST_ARCH=$$(uname -m ) ; \
146+ if [ " $$ HOST_ARCH" = " aarch64" ]; then \
147+ if [ " $( strip $( GO_BUILD_ARGS) ) " = " " ]; then \
148+ docker buildx build --quiet --no-cache --platform=linux/amd64 --tag mcad-controller:${TAG} -f ${CURRENT_DIR} /Dockerfile ${CURRENT_DIR} ; \
149+ else \
150+ docker buildx build --no-cache --platform=linux/amd64 --tag mcad-controller:${TAG} --build-arg GO_BUILD_ARGS=$(GO_BUILD_ARGS ) -f ${CURRENT_DIR} /Dockerfile ${CURRENT_DIR} ; \
151+ fi \
152+ else \
153+ if [ " $( strip $( GO_BUILD_ARGS) ) " = " " ]; then \
154+ docker build --quiet --no-cache --tag mcad-controller:${TAG} -f ${CURRENT_DIR} /Dockerfile ${CURRENT_DIR} ; \
155+ else \
156+ docker build --no-cache --tag mcad-controller:${TAG} --build-arg GO_BUILD_ARGS=$(GO_BUILD_ARGS ) -f ${CURRENT_DIR} /Dockerfile ${CURRENT_DIR} ; \
157+ fi \
158+ fi
150159
151160images-podman : verify-tag-name generate-code update-deployment-crds
152161 $(info List executable directory)
0 commit comments