File tree Expand file tree Collapse file tree 3 files changed +24
-14
lines changed
Expand file tree Collapse file tree 3 files changed +24
-14
lines changed Original file line number Diff line number Diff line change @@ -111,12 +111,19 @@ jobs:
111111 with :
112112 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
113113
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+
114120 - name : Build and push Docker image
115121 id : push
116122 uses : docker/build-push-action@v6
117123 with :
118124 context : .
119125 push : true
126+ platforms : linux/amd64,linux/arm64
120127 tags : ${{ steps.meta.outputs.tags }}
121128 labels : ${{ steps.meta.outputs.labels }}
122129
Original file line number Diff line number Diff line change 1- FROM golang:latest AS builder
1+ FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:latest AS builder
2+
3+ ARG BUILDPLATFORM
4+ ARG TARGETPLATFORM
5+ ARG TARGETOS
6+ ARG TARGETARCH
27
38ENV GO111MODULE=on \
49 CGO_ENABLED=0
@@ -11,19 +16,14 @@ COPY go.sum .
1116RUN go mod download
1217
1318COPY . .
14- RUN make build
19+ RUN OS=${TARGETOS} ARCH=${TARGETARCH} make build
1520
1621WORKDIR /dist
1722
1823RUN 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-
2424RUN mkdir /data && cp /build/deploy/cortex-tenant.yml /data/cortex-tenant.yml
2525
26- FROM scratch
26+ FROM --platform=${TARGETPLATFORM:-linux/amd64} scratch
2727
2828COPY --chown=65534:0 --from=builder /dist /
2929
Original file line number Diff line number Diff line change @@ -10,13 +10,16 @@ RELEASE := 1
1010GO ?= go
1111OUT := .out
1212
13+ OS ?= linux
14+ ARCH ?= amd64
15+
1316all : rpm deb
1417
1518build :
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 ./...
2023 $(GO ) build -ldflags " -s -w -extldflags \" -static\" -X main.Version=$( VERSION) "
2124
2225prepare :
@@ -52,7 +55,7 @@ build-rpm:
5255 --description "$(DESCRIPTION)" \
5356 -m "$(MAINTAINER)" \
5457 --license "$(LICENSE)" \
55- -a amd64 \
58+ -a $(ARCH) \
5659 .
5760
5861build-deb :
@@ -76,5 +79,5 @@ build-deb:
7679 --description "$(DESCRIPTION)" \
7780 -m "$(MAINTAINER)" \
7881 --license "$(LICENSE)" \
79- -a amd64 \
82+ -a $(ARCH) \
8083 .
You can’t perform that action at this time.
0 commit comments