Skip to content
This repository was archived by the owner on Oct 14, 2025. It is now read-only.

Commit 3f03136

Browse files
committed
build for arm64 too
1 parent cbf2749 commit 3f03136

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Dockerfile

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@
22

33
# STEP 1: Build kindnetd binary
44
FROM --platform=$BUILDPLATFORM golang:1.23 AS builder
5+
ARG TARGETARCH BUILDPLATFORM
56
# copy in sources
67
WORKDIR /src
78
COPY . .
89
# build
9-
ARG TARGETARCH
1010
RUN CGO_ENABLED=0 GOARCH=$TARGETARCH go build -o /go/bin/kindnetd ./cmd/kindnetd
1111
WORKDIR /src/cmd/cni-kindnet
1212
# sqlite requires CGO
13-
RUN CGO_ENABLED=1 GOARCH=$TARGETARCH go build -o /go/bin/cni-kindnet .
13+
RUN if [ "$TARGETARCH" = "arm64" ] ; then \
14+
apt-get update && apt-get -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu ;\
15+
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOARCH=$TARGETARCH go build -o /go/bin/cni-kindnet . ;\
16+
else \
17+
CGO_ENABLED=1 GOARCH=$TARGETARCH go build -o /go/bin/cni-kindnet . ;\
18+
fi
1419

1520
# STEP 2: Build small image
16-
FROM registry.k8s.io/build-image/distroless-iptables:v0.6.5
21+
FROM --platform=${BUILDPLATFORM} registry.k8s.io/build-image/distroless-iptables:v0.6.6
1722
COPY --from=builder --chown=root:root /go/bin/kindnetd /bin/kindnetd
1823
COPY --from=builder --chown=root:root /go/bin/cni-kindnet /opt/cni/bin/cni-kindnet
1924
CMD ["/bin/kindnetd"]

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ lint:
2222
hack/lint.sh
2323

2424
update:
25-
go mod tidy && go mod vendor
25+
go mod tidy
2626

2727
# get image name from directory we're building
2828
IMAGE_NAME=kindnetd
@@ -32,9 +32,11 @@ REGISTRY?=ghcr.io/aojea
3232
TAG?=$(shell echo "$$(date +v%Y%m%d)-$$(git describe --always --dirty)")
3333
# the full image tag
3434
IMAGE?=$(REGISTRY)/$(IMAGE_NAME):$(TAG)
35-
35+
PLATFORMS?=linux/amd64,linux/arm64
3636
# required to enable buildx
3737
export DOCKER_CLI_EXPERIMENTAL=enabled
38+
3839
image-build:
39-
# docker buildx build --platform=${PLATFORMS} $(OUTPUT) --progress=$(PROGRESS) -t ${IMAGE} --pull $(EXTRA_BUILD_OPT) .
40-
docker build . -t ${IMAGE} --load
40+
docker buildx build . \
41+
--platform="${PLATFORMS}" \
42+
--tag="${IMAGE}"

0 commit comments

Comments
 (0)