Skip to content

Commit a79ab86

Browse files
committed
refactor: allows for a docker build if the building machine is arm (apple silicon)
1 parent d78eb63 commit a79ab86

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

Makefile

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,16 +165,28 @@ ${BIN_DIR}/deepcopy-gen:
165165
$(info Compiling deepcopy-gen...)
166166
go build -o ${BIN_DIR}/deepcopy-gen ./cmd/deepcopy-gen/
167167

168+
169+
# Build the docker image and tag it.
168170
images: verify-tag-name generate-code update-deployment-crds
169171
$(info List executable directory)
170172
$(info repo id: ${git_repository_id})
171173
$(info branch: ${GIT_BRANCH})
172174
$(info Build the docker image)
173-
ifeq ($(strip $(GO_BUILD_ARGS)),)
174-
docker build --quiet --no-cache --tag mcad-controller:${TAG} -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}
175-
else
176-
docker build --no-cache --tag mcad-controller:${TAG} --build-arg GO_BUILD_ARGS=$(GO_BUILD_ARGS) -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}
177-
endif
175+
echo "Host architecture: $(shell uname -m)"
176+
@HOST_ARCH=$(shell uname -m); \
177+
if [ "$$HOST_ARCH" = "arm64" ]; then \
178+
if [ "$(strip $(GO_BUILD_ARGS))" = "" ]; then \
179+
docker buildx build --platform linux/amd64 --no-cache --tag mcad-controller:${TAG} -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}; \
180+
else \
181+
docker buildx build --platform linux/amd64 --no-cache --tag mcad-controller:${TAG} --build-arg GO_BUILD_ARGS=$(GO_BUILD_ARGS) -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}; \
182+
fi \
183+
else \
184+
if [ "$(strip $(GO_BUILD_ARGS))" = "" ]; then \
185+
docker build --no-cache --tag mcad-controller:${TAG} -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}; \
186+
else \
187+
docker build --no-cache --tag mcad-controller:${TAG} --build-arg GO_BUILD_ARGS=$(GO_BUILD_ARGS) -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}; \
188+
fi \
189+
fi
178190

179191
images-podman: verify-tag-name generate-code update-deployment-crds
180192
$(info List executable directory)

0 commit comments

Comments
 (0)