Skip to content
This repository has been archived by the owner on Jul 10, 2024. It is now read-only.

Commit

Permalink
Support multiarch builds for linux/amd64, linux/arm64 (#5)
Browse files Browse the repository at this point in the history
* Support multiarch builds for linux/amd64, linux/arm64

* Set platform in dockerfile
  • Loading branch information
kgtw authored May 16, 2022
1 parent 384523e commit 2a331c9
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ jobs:
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM golang:1.17 as builder
FROM --platform=${BUILDPLATFORM} golang:1.17 as builder
WORKDIR $GOPATH/src/github.com/transferwise/oomie
COPY . $GOPATH/src/github.com/transferwise/oomie
RUN make build
ARG TARGETOS=linux
ARG TARGETARCH=amd64
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH make build

FROM gcr.io/distroless/static-debian10
COPY --from=builder /go/src/github.com/transferwise/oomie/bin/oomie /oomie
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
all: deps build

ENVVAR = GOOS=linux GOARCH=amd64
GOOS ?= linux
GOARCH ?= amd64
APP_NAME = oomie

clean:
Expand All @@ -13,6 +14,6 @@ fmt:
find . -path ./vendor -prune -o -name '*.go' -print | xargs -L 1 -I % gofmt -s -w %

build: clean fmt deps
$(ENVVAR) CGO_ENABLED=0 go build -mod vendor -o ./bin/$(APP_NAME)
GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_ENABLED=0 go build -mod vendor -o ./bin/$(APP_NAME)

.PHONY: all clean deps fmt build container
39 changes: 36 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,44 @@ go 1.17

require (
github.com/google/cadvisor v0.44.1
github.com/hpcloud/tail v1.0.0 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/magefile/mage v1.11.0 // indirect
github.com/sirupsen/logrus v1.8.1
k8s.io/api v0.23.6
k8s.io/apimachinery v0.23.6
k8s.io/client-go v0.23.6
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/euank/go-kmsg-parser v2.0.0+incompatible // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/hpcloud/tail v1.0.0 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/magefile/mage v1.11.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sys v0.0.0-20211116061358-0a5406a5449c // indirect
golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

0 comments on commit 2a331c9

Please sign in to comment.