Skip to content

Commit c470c59

Browse files
authored
fix: update build targets to work on arm64 (#171)
- Adds scripts/sysbox_sha.sh to properly handle both amd64 and arm64 architectures - Updates Makefile to fetch SYSBOX_SHA from above
1 parent 8b99d48 commit c470c59

2 files changed

Lines changed: 26 additions & 6 deletions

File tree

Makefile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,28 @@
11
PROJECT_ROOT := $(shell git rev-parse --show-toplevel)
22
GO_FILES := $(shell git ls-files '*.go' '*.sum')
33
IMAGE_FILES := $(shell find deploy)
4-
ARCH ?= linux/amd64
5-
SYSBOX_SHA ?= eeff273671467b8fa351ab3d40709759462dc03d9f7b50a1b207b37982ce40a9
4+
ARCH ?= linux/$(shell go env GOARCH)
5+
SYSBOX_SHA ?= $(shell ./scripts/sysbox_sha.sh $(ARCH))
6+
GOOS := $(word 1,$(subst /, ,$(ARCH)))
7+
GOARCH := $(word 2,$(subst /, ,$(ARCH)))
68

79
.PHONY: clean
810
clean:
911
rm -rf build
1012

13+
.PHONY: build/envbox
1114
build/envbox: $(GO_FILES)
12-
CGO_ENABLED=0 go build -o build/envbox ./cmd/envbox
15+
mkdir -p $(@D)
16+
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o build/envbox ./cmd/envbox
1317

1418
.PHONY: build/image/envbox
15-
build/image/envbox: build/image/envbox/.ctx
19+
build/image/envbox: build/image/envbox/$(GOOS)_$(GOARCH)/.ctx
1620

17-
build/image/envbox/.ctx: build/envbox $(IMAGE_FILES)
21+
build/image/envbox/$(GOOS)_$(GOARCH)/.ctx: build/envbox $(IMAGE_FILES) scripts/sysbox_sha.sh
22+
rm -rf $(@D)
1823
mkdir -p $(@D)
1924
cp -r build/envbox deploy/. $(@D)
20-
docker buildx build --build-arg SYSBOX_SHA=$(SYSBOX_SHA) -t envbox --platform $(ARCH) $(@D)
25+
docker buildx build --build-arg SYSBOX_SHA=$(SYSBOX_SHA) --load -t envbox --platform $(ARCH) $(@D)
2126
touch $@
2227

2328
.PHONY: fmt

scripts/sysbox_sha.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
case "${1:-linux/$(go env GOARCH)}" in
5+
linux/amd64)
6+
printf '%s\n' 'eeff273671467b8fa351ab3d40709759462dc03d9f7b50a1b207b37982ce40a9'
7+
;;
8+
linux/arm64)
9+
printf '%s\n' 'eae9c0e91ddd39bd1826d6a7a313a73d42a8449ef5113e9d6d118b559cb809ba'
10+
;;
11+
*)
12+
echo "unsupported architecture: ${1:-}" >&2
13+
exit 1
14+
;;
15+
esac

0 commit comments

Comments
 (0)