Refactoring Makefile

- add `help.mk`
- add target to build and publish image
- update README

Signed-off-by: Evgeniy Kulikov <kim@nspcc.ru>
This commit is contained in:
Evgeniy Kulikov 2021-02-08 12:45:18 +03:00
parent 0861d7bb9b
commit cdc21422ff
4 changed files with 44 additions and 16 deletions

View file

@ -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 <target>'
@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) .
-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)

View file

@ -1,5 +1,24 @@
# NeoFS S3 Gate
S3Gate provides API compatible with Amazon S3 cloud storage service.
## Notable make targets
```
Usage:
make <target>
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
```

2
go.sum
View file

@ -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=

11
help.mk Normal file
View file

@ -0,0 +1,11 @@
.PHONY: help
# Show this help prompt
help:
@echo ' Usage:'
@echo ''
@echo ' make <target>'
@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