Skip to content

Commit bc1ea30

Browse files
authored
Multi-platform build (linux/amd64 and linux/arm64) (#230)
* wip * pin to latest version, not commit * test run * Revert "test run" This reverts commit 355e8f8.
1 parent 5f993e3 commit bc1ea30

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

.github/workflows/publish.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ jobs:
2424
with:
2525
persist-credentials: false
2626

27+
- name: Set up QEMU
28+
uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0
29+
with:
30+
platforms: linux/amd64,linux/arm64
31+
32+
- name: Set up Docker Buildx
33+
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
34+
2735
- name: Log in to the Container registry
2836
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f
2937
with:
@@ -41,6 +49,7 @@ jobs:
4149
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a
4250
with:
4351
context: .
52+
platforms: linux/amd64,linux/arm64
4453
push: true
4554
tags: ${{ steps.meta.outputs.tags }}
4655
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.26.5-alpine AS builder
1+
FROM --platform=$BUILDPLATFORM golang:1.26.5-alpine AS builder
22

33
WORKDIR /src
44

@@ -12,8 +12,9 @@ RUN go mod download
1212
# Copy source code
1313
COPY . .
1414

15-
# Build the binary
16-
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /proxy ./cmd/proxy
15+
# Build the binary for the target platform
16+
ARG TARGETARCH
17+
RUN CGO_ENABLED=0 GOOS=linux GOARCH=${TARGETARCH} go build -ldflags="-s -w" -o /proxy ./cmd/proxy
1718

1819
FROM alpine:3.24.1
1920

0 commit comments

Comments
 (0)