diff --git a/.github/workflows/reusable-build-and-push.yml b/.github/workflows/reusable-build-and-push.yml index 6e070e4..e20b536 100644 --- a/.github/workflows/reusable-build-and-push.yml +++ b/.github/workflows/reusable-build-and-push.yml @@ -62,6 +62,7 @@ jobs: uses: docker/build-push-action@v4 with: context: . + platforms: linux/amd64,linux/arm64 tags: ghcr.io/openclarity/grype-server:${{ inputs.image_tag }} file: Dockerfile push: ${{ inputs.push }} diff --git a/Dockerfile b/Dockerfile index b4cadd8..35d359d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.20.4-alpine AS builder +FROM --platform=$BUILDPLATFORM golang:1.20.4-alpine AS builder RUN apk add --update --no-cache gcc g++ @@ -11,7 +11,11 @@ RUN go mod download # Copy and build backend code COPY grype-server . -RUN go build -o grype-server ./cmd/grype-server/main.go + +ARG TARGETOS +ARG TARGETARCH + +RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o grype-server ./cmd/grype-server/main.go FROM alpine:3.17