Skip to content

Commit 3556fee

Browse files
authored
Plumbing to optionally build for arm64 (#266)
Signed-off-by: Nick Rogers <[email protected]>
1 parent 9603d84 commit 3556fee

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export GOROOT=$(BIN_DIR)/go/
1313
export GOBIN = $(GOROOT)/bin/
1414
export PATH := $(GOBIN):$(PATH):$(BIN_DIR)
1515
GOPATH = $(CURDIR)/.gopath
16+
GOARCH ?= amd64
1617
ORG_PATH = github.com/k8snetworkplumbingwg
1718
PACKAGE = ovs-cni
1819
OCI_BIN ?= $(shell if podman ps >/dev/null 2>&1; then echo podman; elif docker ps >/dev/null 2>&1; then echo docker; fi)
@@ -44,7 +45,7 @@ lint: $(GO) $(GOLANGCI)
4445
$(GOLANGCI) run
4546

4647
build-%: $(GO)
47-
cd cmd/$* && $(GO) fmt && $(GO) vet && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on $(GO) build -tags no_openssl -mod vendor
48+
cd cmd/$* && $(GO) fmt && $(GO) vet && GOOS=linux GOARCH=$(GOARCH) CGO_ENABLED=0 GO111MODULE=on $(GO) build -tags no_openssl -mod vendor
4849

4950
format: $(GO)
5051
$(GO) fmt ./pkg/... ./cmd/...
@@ -74,7 +75,7 @@ functest: $(GO)
7475

7576
docker-build:
7677
hack/get_version.sh > .version
77-
$(OCI_BIN) build -t ${REGISTRY}/ovs-cni-plugin:${IMAGE_TAG} -f ./cmd/Dockerfile .
78+
$(OCI_BIN) build --build-arg goarch=${GOARCH} -t ${REGISTRY}/ovs-cni-plugin:${IMAGE_TAG} -f ./cmd/Dockerfile .
7879

7980
docker-push:
8081
$(OCI_BIN) push ${TLS_SETTING} ${REGISTRY}/ovs-cni-plugin:${IMAGE_TAG}

cmd/Dockerfile

+3-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ RUN dnf install -y golang-$(sed -En 's/^go +(.*+)$/\1/p' go.mod).*
99
COPY . .
1010

1111
ENV GOOS linux
12-
ENV GOARCH amd64
12+
# Support overriding target GOARCH during `make docker-build`
13+
ARG goarch=amd64
14+
ENV GOARCH=$goarch
1315
ENV CGO_ENABLED 0
1416
ENV GOFLAGS -mod=vendor
1517

hack/install-go.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
destination=$1
44
version=1.18.4
5-
tarball=go$version.linux-amd64.tar.gz
5+
arch="$(arch | sed s'/aarch64/arm64/' | sed s'/x86_64/amd64/')"
6+
tarball=go$version.linux-$arch.tar.gz
67
url=https://dl.google.com/go/
78

89
mkdir -p $destination

0 commit comments

Comments
 (0)