@@ -3,6 +3,7 @@ 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+ ARCH := $(shell uname -m)
67# define the GO_BUILD_ARGS if you need to pass additional arguments to the go build
78GO_BUILD_ARGS? =
89
@@ -76,16 +77,49 @@ ${BIN_DIR}/deepcopy-gen:
7677 $(info Compiling deepcopy-gen...)
7778 go build -o ${BIN_DIR} /deepcopy-gen ./cmd/deepcopy-gen/
7879
80+ # Build the docker image and tag it.
81+ # images: verify-tag-name generate-code update-deployment-crds
82+ # $(info List executable directory)
83+ # $(info repo id: ${git_repository_id})
84+ # $(info branch: ${GIT_BRANCH})
85+ # $(info Build the docker image)
86+ # ARCH := $(shell uname -m)
87+ # ifeq ($(ARCH),aarch64)
88+ # ifeq ($(strip $(GO_BUILD_ARGS)),)
89+ # docker buildx build --quiet --no-cache --platform=linux/amd64 --tag mcad-controller:${TAG} -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}
90+ # else
91+ # 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}
92+ # endif
93+ # else
94+ # ifeq ($(strip $(GO_BUILD_ARGS)),)
95+ # docker build --quiet --no-cache --tag mcad-controller:${TAG} -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}
96+ # else
97+ # docker build --no-cache --tag mcad-controller:${TAG} --build-arg GO_BUILD_ARGS=$(GO_BUILD_ARGS) -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}
98+ # endif
99+ # endif
100+
101+
102+ # Build the docker image and tag it.
79103images : verify-tag-name generate-code update-deployment-crds
80104 $(info List executable directory)
81105 $(info repo id: ${git_repository_id})
82106 $(info branch: ${GIT_BRANCH})
83107 $(info Build the docker image)
84- ifeq ($(strip $(GO_BUILD_ARGS ) ) ,)
85- docker build --quiet --no-cache --tag mcad-controller:${TAG} -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}
86- else
87- docker build --no-cache --tag mcad-controller:${TAG} --build-arg GO_BUILD_ARGS=$(GO_BUILD_ARGS) -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}
88- endif
108+ @HOST_ARCH=$$(uname -m ) ; \
109+ if [ " $$ HOST_ARCH" = " aarch64" ]; then \
110+ if [ " $( strip $( GO_BUILD_ARGS) ) " = " " ]; then \
111+ docker buildx build --quiet --no-cache --platform=linux/amd64 --tag mcad-controller:${TAG} -f ${CURRENT_DIR} /Dockerfile ${CURRENT_DIR} ; \
112+ else \
113+ 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} ; \
114+ fi \
115+ else \
116+ if [ " $( strip $( GO_BUILD_ARGS) ) " = " " ]; then \
117+ docker build --quiet --no-cache --tag mcad-controller:${TAG} -f ${CURRENT_DIR} /Dockerfile ${CURRENT_DIR} ; \
118+ else \
119+ docker build --no-cache --tag mcad-controller:${TAG} --build-arg GO_BUILD_ARGS=$(GO_BUILD_ARGS ) -f ${CURRENT_DIR} /Dockerfile ${CURRENT_DIR} ; \
120+ fi \
121+ fi
122+
89123
90124images-podman : verify-tag-name generate-code update-deployment-crds
91125 $(info List executable directory)
@@ -158,4 +192,4 @@ ${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_schedulingspecs.yaml : ${CRD_BASE_DIR}/mcad.i
158192
159193
160194$(DEPLOYMENT_CRD_DIR ) /% : ${CRD_BASE_DIR}/%
161- cp $< $@
195+ cp $< $@
0 commit comments