Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for arm64 builds #42

Merged
merged 2 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ godeps = *.go go.mod go.sum
cover_out = cover.out
cover_html = cover.html

ARCH ?= amd64

all: lint test $(binary)

.PHONY: lint
Expand All @@ -24,7 +26,7 @@ $(cover_html): $(cover_out)
go tool cover -html=$(cover_out) -o $(cover_html)

$(binary): $(godeps)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w" -buildvcs=false -o $(binary)
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH) go build -trimpath -ldflags="-s -w" -buildvcs=false -o $(binary)

.PHONY: clean
clean:
Expand Down
3 changes: 2 additions & 1 deletion example/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ WORKDIR /

# Clone the repository and build the stand-alone nitriding executable.
RUN git clone https://github.com/brave/nitriding-daemon.git
RUN make -C nitriding-daemon/ nitriding
ARG TARGETARCH
RUN ARCH=${TARGETARCH} make -C nitriding-daemon/ nitriding

# Use the intermediate builder image to add our files. This is necessary to
# avoid intermediate layers that contain inconsistent file permissions.
Expand Down
13 changes: 12 additions & 1 deletion example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ image_tag := $(prog):$(version)
image_tar := $(prog)-$(version)-kaniko.tar
image_eif := $(image_tar:%.tar=%.eif)

ARCH ?= $(shell uname -m)
ifeq ($(ARCH),aarch64)
override ARCH=arm64
endif
ifeq ($(ARCH),x86_64)
override ARCH=amd64
endif

.PHONY: all
all: run

Expand All @@ -18,7 +26,10 @@ $(image_tar): Dockerfile service.py start.sh
--no-push \
--tarPath $(image_tar) \
--destination $(image_tag) \
--custom-platform linux/amd64
--build-arg TARGETPLATFORM=linux/$(ARCH) \
--build-arg TARGETOS=linux \
--build-arg TARGETARCH=$(ARCH) \
--custom-platform linux/$(ARCH)

$(image_eif): $(image_tar)
docker load -i $<
Expand Down
Loading