Skip to content

Commit

Permalink
Merge pull request #42 from bastionplatforms/arm64-example
Browse files Browse the repository at this point in the history
Add support for arm64 builds
  • Loading branch information
rillian authored Feb 5, 2024
2 parents 5e117aa + 3374753 commit 2bb40ff
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
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

0 comments on commit 2bb40ff

Please sign in to comment.