From e73719b9b5c4b6f20e9e2bbfa01e315a8d5e69dc Mon Sep 17 00:00:00 2001 From: taiyoh Date: Mon, 9 Mar 2020 20:36:58 +0900 Subject: [PATCH 1/3] update aws-sdk-go --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index b3ba582..9b7298f 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/taiyoh/toyhose go 1.13 require ( - github.com/aws/aws-sdk-go v1.29.10 + github.com/aws/aws-sdk-go v1.29.19 github.com/google/uuid v1.1.1 github.com/kelseyhightower/envconfig v1.4.0 github.com/rs/zerolog v1.18.0 diff --git a/go.sum b/go.sum index cbc02f5..b490ba6 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/aws/aws-sdk-go v1.29.10 h1:QJOQq1xNmdrY5mXUmC8CHXzZPve8134Bx/Ux0o6s38s= -github.com/aws/aws-sdk-go v1.29.10/go.mod h1:1KvfttTE3SPKMpo8g2c6jL3ZKfXtFvKscTgahTma5Xg= +github.com/aws/aws-sdk-go v1.29.19 h1:+jifYixffn6kzWygtGWFWQMv0tDGyISZHNwugF9V2sE= +github.com/aws/aws-sdk-go v1.29.19/go.mod h1:1KvfttTE3SPKMpo8g2c6jL3ZKfXtFvKscTgahTma5Xg= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= From 455aca92270864387adda9bc682b7fd49d29686f Mon Sep 17 00:00:00 2001 From: taiyoh Date: Mon, 9 Mar 2020 21:09:59 +0900 Subject: [PATCH 2/3] refactor make task for building docker image --- Makefile | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 9341a3f..6fd4f02 100644 --- a/Makefile +++ b/Makefile @@ -2,25 +2,27 @@ GIT_VERSION=$(shell git describe --tags) CURRENT_REVISION=$(shell git rev-parse --short HEAD) LDFLAGS="-s -w -X main.version=$(GIT_VERSION) -X main.commit=$(CURRENT_REVISION)" -.PHONY: test install build release docker +.PHONY: build release docker clean -install: - cd cmd/toyhose && go install +clean: + rm -rf pkg/$(GIT_VERSION)/ && mkdir -p pkg/$(GIT_VERSION)/dist -test: - docker-compose up -d - go test -v -race -timeout 30s - docker-compose down +pkg/$(GIT_VERSION)/toyhose_darwin_amd64/toyhose: + CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o pkg/$(GIT_VERSION)/toyhose_darwin_amd64/toyhose -ldflags=$(LDFLAGS) cmd/toyhose/main.go -build: - rm -rf pkg/$(GIT_VERSION)/ && mkdir -p pkg/$(GIT_VERSION)/dist - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pkg/$(GIT_VERSION)/toyhose_linux_amd64/toyhose -ldflags=$(LDFLAGS) cmd/toyhose/main.go - cd pkg/$(GIT_VERSION)/toyhose_linux_amd64 && tar cvzf toyhose_$(GIT_VERSION)_linux_amd64.tar.gz toyhose && mv toyhose_$(GIT_VERSION)_linux_amd64.tar.gz ../dist - CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o pkg/$(GIT_VERSION)/toyhose_darwin_amd64/toyhose -ldflags=$(LDFLAGS) cmd/toyhose/main.go +pkg/$(GIT_VERSION)/toyhose_darwin_amd64/toyhose_$(GIT_VERSION)_darwin_amd64.zip: pkg/$(GIT_VERSION)/toyhose_darwin_amd64/toyhose cd pkg/$(GIT_VERSION)/toyhose_darwin_amd64 && zip toyhose_$(GIT_VERSION)_darwin_amd64.zip * && mv toyhose_$(GIT_VERSION)_darwin_amd64.zip ../dist +pkg/$(GIT_VERSION)/toyhose_linux_amd64/toyhose: + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pkg/$(GIT_VERSION)/toyhose_linux_amd64/toyhose -ldflags=$(LDFLAGS) cmd/toyhose/main.go + +pkg/$(GIT_VERSION)/toyhose_linux_amd64/toyhose_$(GIT_VERSION)_linux_amd64.tar.gz: pkg/$(GIT_VERSION)/toyhose_linux_amd64/toyhose + cd pkg/$(GIT_VERSION)/toyhose_linux_amd64 && tar cvzf toyhose_$(GIT_VERSION)_linux_amd64.tar.gz toyhose && mv toyhose_$(GIT_VERSION)_linux_amd64.tar.gz ../dist + +build: clean pkg/$(GIT_VERSION)/toyhose_linux_amd64/toyhose_$(GIT_VERSION)_linux_amd64.tar.gz pkg/$(GIT_VERSION)/toyhose_darwin_amd64/toyhose_$(GIT_VERSION)_darwin_amd64.zip + release: ghr -n $(GIT_VERSION) $(GIT_VERSION) pkg/$(GIT_VERSION)/dist -docker: build - docker build -t taiyoh/toyhose:$(GIT_VERSION) --build-arg version=$(GIT_VERSION) . +docker: clean pkg/$(GIT_VERSION)/toyhose_linux_amd64/toyhose + mv pkg/$(GIT_VERSION)/toyhose_linux_amd64/toyhose /bin/toyhose From 2528d6f9f77dcb8841bf9c0f06b1f80c45ebca8d Mon Sep 17 00:00:00 2001 From: taiyoh Date: Mon, 9 Mar 2020 21:14:26 +0900 Subject: [PATCH 3/3] refine Dockerfile --- Dockerfile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index f1a1562..f2a9d79 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,12 @@ -FROM scratch +FROM golang:1.13.8-buster AS toyhose-builder + +ADD . /app +WORKDIR /app -ARG version +RUN make docker + +FROM scratch -ADD ./pkg/${version}/toyhose_linux_amd64/toyhose . +COPY --from=toyhose-builder /bin/toyhose ./toyhose CMD [ "./toyhose" ]