Skip to content

Commit

Permalink
fix multi-platform build (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
BretFisher authored Apr 22, 2023
1 parent d9f32a1 commit 6c275d1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/call-docker-build-promote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ jobs:
dockerhub-enable: false
ghcr-enable: true
push: true
platforms: linux/amd64,linux/arm64
image-names: |
ghcr.io/${{ github.repository }}
scan-pr:
name: CVE Scan
if: github.event_name == 'pull_request'
needs: docker-build-pr
permissions:
permissions:
packages: read
uses: mostlydevops/actions/.github/workflows/reusable-trivy-scan-image.yaml@main
secrets:
Expand All @@ -61,10 +62,11 @@ jobs:
packages: write
pull-requests: write
uses: mostlydevops/actions/.github/workflows/reusable-docker-build.yaml@main
with:
with:
dockerhub-enable: false
ghcr-enable: true
push: true
platforms: linux/amd64,linux/arm64
image-names: |
ghcr.io/${{ github.repository }}
ghcr.io/${{ github.repository }}-stable
Expand Down
21 changes: 15 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# BUILD
FROM golang:alpine as builder
# use the build platforms matching arch rather than target arch
FROM --platform=$BUILDPLATFORM golang:alpine as builder

ARG TARGETARCH

WORKDIR /go

COPY dispatcher.go .
RUN go build dispatcher.go

# build for the target arch not the build platform host arch
RUN GOOS=linux GOARCH=$TARGETARCH go build dispatcher.go

# RUN
FROM alpine
# defaults to using the target arch image
FROM scratch as run

COPY --from=builder /go/dispatcher /dispatcher
COPY static /static/

EXPOSE 80
CMD ["/dispatcher"]

COPY --from=builder /go/dispatcher /
COPY static /static/
CMD ["/dispatcher"]

0 comments on commit 6c275d1

Please sign in to comment.