Skip to content

Commit 692e370

Browse files
committed
refactor: allows for a docker build if the building machine is arm (apple silicon)
1 parent 6fb5e32 commit 692e370

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
@@ -91,16 +91,28 @@ ${BIN_DIR}/deepcopy-gen:
9191
$(info Compiling deepcopy-gen...)
9292
go build -o ${BIN_DIR}/deepcopy-gen ./cmd/deepcopy-gen/
9393

94+
95+
# Build the docker image and tag it.
9496
images: verify-tag-name generate-code update-deployment-crds
9597
$(info List executable directory)
9698
$(info repo id: ${git_repository_id})
9799
$(info branch: ${GIT_BRANCH})
98100
$(info Build the docker image)
99-
ifeq ($(strip $(GO_BUILD_ARGS)),)
100-
docker build --quiet --no-cache --tag mcad-controller:${TAG} -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}
101-
else
102-
docker build --no-cache --tag mcad-controller:${TAG} --build-arg GO_BUILD_ARGS=$(GO_BUILD_ARGS) -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}
103-
endif
101+
echo "Host architecture: $(shell uname -m)"
102+
@HOST_ARCH=$(shell uname -m); \
103+
if [ "$$HOST_ARCH" = "arm64" ]; then \
104+
if [ "$(strip $(GO_BUILD_ARGS))" = "" ]; then \
105+
docker buildx build --platform linux/amd64 --no-cache --tag mcad-controller:${TAG} -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}; \
106+
else \
107+
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}; \
108+
fi \
109+
else \
110+
if [ "$(strip $(GO_BUILD_ARGS))" = "" ]; then \
111+
docker build --no-cache --tag mcad-controller:${TAG} -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}; \
112+
else \
113+
docker build --no-cache --tag mcad-controller:${TAG} --build-arg GO_BUILD_ARGS=$(GO_BUILD_ARGS) -f ${CURRENT_DIR}/Dockerfile ${CURRENT_DIR}; \
114+
fi \
115+
fi
104116

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

0 commit comments

Comments
 (0)