Skip to content

Commit f27a1e2

Browse files
authored
feat: add multi-arch build (amd64 + arm64) (#21)
* feat: add multi-arch build (amd64 + arm64) Add QEMU and platform support to build Docker images for both linux/amd64 and linux/arm64 architectures. * perf: use native Go cross-compilation instead of QEMU emulation
1 parent 1874e1d commit f27a1e2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.github/workflows/release.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ jobs:
2626
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
2727
type=sha
2828
29+
- name: Set up QEMU
30+
uses: docker/setup-qemu-action@v3
31+
2932
- name: Set up Docker Buildx
3033
id: buildx
3134
uses: docker/setup-buildx-action@v3
@@ -41,6 +44,7 @@ jobs:
4144
uses: docker/build-push-action@v5
4245
with:
4346
context: .
47+
platforms: linux/amd64,linux/arm64
4448
build-args: |
4549
versionflags=-X 'main.appVersion=${{ github.ref_name }}'
4650
push: ${{ github.event_name != 'pull_request' }}

Dockerfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# https://hub.docker.com/_/golang
2-
FROM docker.io/library/golang:1.25.3-alpine AS build
2+
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.25.3-alpine AS build
33

4+
ARG TARGETARCH
45
ARG versionflags=""
56

67
WORKDIR /src
@@ -9,7 +10,7 @@ COPY . .
910

1011
RUN go mod download
1112

12-
RUN CGO_ENABLED=0 go build -o webhook -ldflags "-w -s -extldflags '-static' ${versionflags}" .
13+
RUN CGO_ENABLED=0 GOARCH=${TARGETARCH} go build -o webhook -ldflags "-w -s -extldflags '-static' ${versionflags}" .
1314

1415
FROM gcr.io/distroless/static-debian12:nonroot AS webhook
1516

0 commit comments

Comments
 (0)