File tree Expand file tree Collapse file tree 3 files changed +23
-13
lines changed Expand file tree Collapse file tree 3 files changed +23
-13
lines changed Original file line number Diff line number Diff line change @@ -111,12 +111,19 @@ jobs:
111
111
with :
112
112
images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
113
113
114
+ - name : Set up QEMU
115
+ uses : docker/setup-qemu-action@v3
116
+
117
+ - name : Set up Docker Buildx
118
+ uses : docker/setup-buildx-action@v3
119
+
114
120
- name : Build and push Docker image
115
121
id : push
116
122
uses : docker/build-push-action@v6
117
123
with :
118
124
context : .
119
125
push : true
126
+ platforms : linux/amd64,linux/arm64
120
127
tags : ${{ steps.meta.outputs.tags }}
121
128
labels : ${{ steps.meta.outputs.labels }}
122
129
Original file line number Diff line number Diff line change 1
1
FROM golang:latest AS builder
2
2
3
+ ARG TARGETOS
4
+ ARG TARGETARCH
5
+
3
6
ENV GO111MODULE=on \
7
+ GOOS=${TARGETOS} \
8
+ GOARCH=${TARGETARCH} \
4
9
CGO_ENABLED=0
5
10
6
11
WORKDIR /build
@@ -11,16 +16,11 @@ COPY go.sum .
11
16
RUN go mod download
12
17
13
18
COPY . .
14
- RUN make build
19
+ RUN OS=${TARGETOS} ARCH=${TARGETARCH} make build
15
20
16
21
WORKDIR /dist
17
22
18
23
RUN cp /build/cortex-tenant ./cortex-tenant
19
-
20
- RUN ldd cortex-tenant | tr -s '[:blank:]' '\n ' | grep '^/' | \
21
- xargs -I % sh -c 'mkdir -p $(dirname ./%); cp % ./%;'
22
- RUN mkdir -p lib64 && cp /lib64/ld-linux-x86-64.so.2 lib64/
23
-
24
24
RUN mkdir /data && cp /build/deploy/cortex-tenant.yml /data/cortex-tenant.yml
25
25
26
26
FROM scratch
Original file line number Diff line number Diff line change @@ -10,13 +10,16 @@ RELEASE := 1
10
10
GO ?= go
11
11
OUT := .out
12
12
13
+ OS ?= linux
14
+ ARCH ?= amd64
15
+
13
16
all : rpm deb
14
17
15
18
build :
16
- go test ./... && \
17
- GOARCH=amd64 \
18
- GOOS=linux \
19
- CGO_ENABLED=0 \
19
+ export GOARCH= $( ARCH )
20
+ export GOOS= $( OS )
21
+ export CGO_ENABLED=0
22
+ go test ./...
20
23
$(GO ) build -ldflags " -s -w -extldflags \" -static\" -X main.Version=$( VERSION) "
21
24
22
25
prepare :
@@ -47,12 +50,12 @@ build-rpm:
47
50
--iteration $(RELEASE) \
48
51
--force \
49
52
--rpm-compression bzip2 \
50
- --rpm-os linux \
53
+ --rpm-os $(OS) \
51
54
--url $(URL) \
52
55
--description "$(DESCRIPTION)" \
53
56
-m "$(MAINTAINER)" \
54
57
--license "$(LICENSE)" \
55
- -a amd64 \
58
+ -a $(ARCH) \
56
59
.
57
60
58
61
build-deb :
@@ -76,5 +79,5 @@ build-deb:
76
79
--description "$(DESCRIPTION)" \
77
80
-m "$(MAINTAINER)" \
78
81
--license "$(LICENSE)" \
79
- -a amd64 \
82
+ -a $(ARCH) \
80
83
.
You can’t perform that action at this time.
0 commit comments