From cdc21422ffe544620bc7a3d1818d16ca3acb56f6 Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Mon, 8 Feb 2021 12:45:18 +0300 Subject: [PATCH] Refactoring Makefile - add `help.mk` - add target to build and publish image - update README Signed-off-by: Evgeniy Kulikov --- Makefile | 28 ++++++++++++++-------------- README.md | 19 +++++++++++++++++++ go.sum | 2 -- help.mk | 11 +++++++++++ 4 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 help.mk diff --git a/Makefile b/Makefile index 68e9fa2..ded7221 100644 --- a/Makefile +++ b/Makefile @@ -1,17 +1,12 @@ +-include .env +-include help.mk + +HUB_IMAGE=nspccdev/neofs + VERSION ?= "$(shell git describe --tags 2>/dev/null || git rev-parse --short HEAD | sed 's/^v//')" BUILD_VERSION ?= "$(shell git describe --abbrev=0 --tags | sed 's/^v//')" -.PHONY: help format deps - -# Show this help prompt -help: - @echo ' Usage:' - @echo '' - @echo ' make ' - @echo '' - @echo ' Targets:' - @echo '' - @awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort | uniq +.PHONY: format deps image publish # Show current version version: @@ -25,7 +20,7 @@ format: goimports -w $$f; \ done -# Make sure that all files added to commit +# Check and ensure dependencies deps: @printf "⇒ Ensure vendor: " @go mod tidy -v && echo OK || (echo fail && exit 2) @@ -35,9 +30,14 @@ deps: @go mod vendor && echo OK || (echo fail && exit 2) # Build current docker image -image-build: deps +image: deps @echo "⇒ Build docker-image" @docker build \ --build-arg VERSION=$(BUILD_VERSION) \ -f Dockerfile \ - -t nspccdev/neofs-s3-gate:$(BUILD_VERSION) . \ No newline at end of file + -t $(HUB_IMAGE)-s3-gate:$(BUILD_VERSION) . + +# Publish docker image +publish: + @echo "${B}${G}⇒ publish docker image ${R}" + @docker push $(HUB_IMAGE)-s3-gate:$(VERSION) \ No newline at end of file diff --git a/README.md b/README.md index 4b5b0af..b688df7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,24 @@ # NeoFS S3 Gate +S3Gate provides API compatible with Amazon S3 cloud storage service. + +## Notable make targets + +``` + Usage: + + make + + Targets: + + deps Check and ensure dependencies + format Reformat code + help Show this help prompt + image Build current docker image + publish Publish docker image + version Show current version +``` + ## Example of configuration ``` diff --git a/go.sum b/go.sum index 0228592..e6791f3 100644 --- a/go.sum +++ b/go.sum @@ -45,8 +45,6 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= -github.com/aws/aws-sdk-go v1.36.28 h1:JVRN7BZgwQ31SQCBwG5QM445+ynJU0ruKu+miFIijYY= -github.com/aws/aws-sdk-go v1.36.28/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go v1.37.1 h1:BTHmuN+gzhxkvU9sac2tZvaY0gV9ihbHw+KxZOecYvY= github.com/aws/aws-sdk-go v1.37.1/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= diff --git a/help.mk b/help.mk new file mode 100644 index 0000000..c065ec8 --- /dev/null +++ b/help.mk @@ -0,0 +1,11 @@ +.PHONY: help + +# Show this help prompt +help: + @echo ' Usage:' + @echo '' + @echo ' make ' + @echo '' + @echo ' Targets:' + @echo '' + @awk '/^#/{ comment = substr($$0,3) } comment && /^[a-zA-Z][a-zA-Z0-9_-]+ ?:/{ print " ", $$1, comment }' $(MAKEFILE_LIST) | column -t -s ':' | grep -v 'IGNORE' | sort | uniq