From 3e885c50401bff9203ab9263d5f9e75cc59a90c8 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Date: Sun, 28 Jan 2018 00:27:53 +0100 Subject: [PATCH] Support ARM arch --- Dockerfile => DockerfileAMD | 2 +- DockerfileARM | 15 +++++++++++++++ Makefile | 36 ++++++++++++++++++++++++++++++------ 3 files changed, 46 insertions(+), 7 deletions(-) rename Dockerfile => DockerfileAMD (92%) create mode 100644 DockerfileARM diff --git a/Dockerfile b/DockerfileAMD similarity index 92% rename from Dockerfile rename to DockerfileAMD index 9d3a3fa..76f4956 100644 --- a/Dockerfile +++ b/DockerfileAMD @@ -1,4 +1,4 @@ -FROM golang:1.8 as builder +FROM golang:1.9 as builder ADD . /go/src/github.com/justwatchcom/github-releases-notifier WORKDIR /go/src/github.com/justwatchcom/github-releases-notifier diff --git a/DockerfileARM b/DockerfileARM new file mode 100644 index 0000000..ec885cc --- /dev/null +++ b/DockerfileARM @@ -0,0 +1,15 @@ +FROM golang:1.9 as builder + +ADD . /go/src/github.com/justwatchcom/github-releases-notifier +WORKDIR /go/src/github.com/justwatchcom/github-releases-notifier + +RUN make buildarm + +FROM arm32v6/alpine:3.7 +RUN apk --no-cache add ca-certificates + +COPY --from=builder \ + /go/src/github.com/justwatchcom/github-releases-notifier/github-releases-notifier \ + /bin/github-releases-notifier + +ENTRYPOINT [ "/bin/github-releases-notifier" ] diff --git a/Makefile b/Makefile index fe27dd7..d9ea0c0 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,8 @@ GOLDFLAGS += -X "main.date=$(DATE)" GOLDFLAGS += -X "main.commit=$(SHA)" GOLDFLAGS += -extldflags '-static' -GO := CGO_ENABLED=0 go +GO := CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go +GOARM := CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 go GOOS ?= $(shell go version | cut -d' ' -f4 | cut -d'/' -f1) GOARCH ?= $(shell go version | cut -d' ' -f4 | cut -d'/' -f2) @@ -23,12 +24,13 @@ PACKAGES ?= $(shell go list ./... | grep -v /vendor/ | grep -v /tests) TAGS ?= netgo .PHONY: all -all: clean test build +all: clean test build buildarm .PHONY: clean clean: $(GO) clean -i ./... find . -type f -name "coverage.out" -delete + if [ -f Dockerfile ]; then rm Dockerfile ; fi .PHONY: fmt fmt: @@ -66,8 +68,30 @@ megacheck: test: STATUS=0; for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || STATUS=1; done; exit $$STATUS -.PHONY: build -build: $(EXECUTABLE)-$(GOOS)-$(GOARCH) - -$(EXECUTABLE)-$(GOOS)-$(GOARCH): $(wildcard *.go) +.PHONE: buildlinux +buildlinux: $(GO) build -tags '$(TAGS)' -ldflags '-s -w $(GOLDFLAGS)' -o $(EXECUTABLE) + +.PHONY: buildarm +buildarm: + $(GOARM) build -tags '$(TAGS)' -ldflags '-s -w $(GOLDFLAGS)' -o $(EXECUTABLE) + +.PHONY: build +build: buildlinux buildarm + +.PHONY: releaseamd64 +releaseamd64: + if [ -f Dockerfile ]; then rm Dockerfile ; fi + ln -s DockerfileAMD Dockerfile + docker build . -t pcarranza/github-releases-notifier:latest + docker push pcarranza/github-releases-notifier:latest + +.PHONY: releasearm +releasearm: + if [ -f Dockerfile ]; then rm Dockerfile ; fi + ln -s DockerfileARM Dockerfile + docker build . -t pcarranza/github-releases-notifier-armv6:latest + docker tag pcarranza/github-releases-notifier-armv6:latest \ + pcarranza/github-releases-notifier-armv6:$(VERSION) + docker push pcarranza/github-releases-notifier-armv6:latest + docker push pcarranza/github-releases-notifier-armv6:$(VERSION)