File tree 2 files changed +14
-5
lines changed
2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 1
- FROM golang:1.22.0@sha256:7b297d9abee021bab9046e492506b3c2da8a3722cbf301653186545ecc1e00bb as gobuilder
1
+ FROM --platform=$BUILDPLATFORM golang:1.22.0@sha256:7b297d9abee021bab9046e492506b3c2da8a3722cbf301653186545ecc1e00bb as gobuilder
2
2
WORKDIR /src/little-vm-helper
3
3
COPY . .
4
- RUN make little-vm-helper
4
+ ARG TARGETARCH
5
+ RUN TARGET_ARCH=$TARGETARCH make little-vm-helper
5
6
6
7
FROM busybox@sha256:6d9ac9237a84afe1516540f40a0fafdc86859b2141954b4d643af7066d598b74
7
8
COPY --from=gobuilder /src/little-vm-helper/lvh /usr/bin/lvh
Original file line number Diff line number Diff line change @@ -8,6 +8,14 @@ GO_BUILD_LDFLAGS =
8
8
GO_BUILD_LDFLAGS += -X 'github.com/cilium/little-vm-helper/pkg/version.Version=$(VERSION ) '
9
9
GO_BUILD_FLAGS += -ldflags "$(GO_BUILD_LDFLAGS ) "
10
10
11
+ UNAME_M := $(shell uname -m)
12
+ ifeq ($(UNAME_M ) ,x86_64)
13
+ TARGET_ARCH ?= amd64
14
+ else ifeq ($(UNAME_M),aarch64)
15
+ TARGET_ARCH ?= arm64
16
+ else
17
+ TARGET_ARCH ?= amd64
18
+ endif
11
19
12
20
all : tests little-vm-helper
13
21
@@ -16,15 +24,15 @@ tests:
16
24
$(GO ) test -cover ./...
17
25
18
26
little-vm-helper : FORCE
19
- CGO_ENABLED=0 $(GO ) build $(GO_BUILD_FLAGS ) ./cmd/lvh
27
+ GOARCH= ${TARGET_ARCH} CGO_ENABLED=0 $(GO ) build $(GO_BUILD_FLAGS ) ./cmd/lvh
20
28
21
29
.PHONY : image
22
30
image :
23
- $(DOCKER ) build -f Dockerfile -t $(OCIREPO ) .
31
+ $(DOCKER ) build -f Dockerfile --platform=linux/ ${TARGET_ARCH} - t $(OCIREPO ) .
24
32
25
33
.PHONY : install
26
34
install :
27
- CGO_ENABLED=0 $(GO ) install ./cmd/lvh
35
+ GOARCH= ${TARGET_ARCH} CGO_ENABLED=0 $(GO ) install ./cmd/lvh
28
36
29
37
clean :
30
38
rm -f lvh
You can’t perform that action at this time.
0 commit comments