From 5b1ea952fe98d3a90bb6cef62e7f499055e8f872 Mon Sep 17 00:00:00 2001 From: Richard87 Date: Tue, 18 Jun 2024 17:35:17 +0200 Subject: [PATCH] Add multiarch output --- .github/workflows/build.yaml | 3 ++- Dockerfile | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 089b86e..426c9ea 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -6,6 +6,7 @@ on: branches: - main workflow_dispatch: + pull_request: env: @@ -46,6 +47,6 @@ jobs: with: context: . push: true + platform: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - diff --git a/Dockerfile b/Dockerfile index 187dd37..4f6d14c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22-alpine3.19 as builder +FROM --platform=$BUILDPLATFORM golang:1.22-alpine3.19 as builder RUN apk update && \ apk add bash jq alpine-sdk sed gawk git ca-certificates curl && \ @@ -14,12 +14,12 @@ RUN go mod download COPY . . # Build project -RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-s -w" -a -installsuffix cgo -o /radix-oauth-guard +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH CGO_ENABLED=0 go build -ldflags "-s -w" -a -installsuffix cgo -o /radix-oauth-guard RUN addgroup -S -g 1000 guard RUN adduser -S -u 1000 -G guard guard -FROM scratch +FROM --platform=$TARGETPLATFORM scratch COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ COPY --from=builder /etc/passwd /etc/passwd