From f1a2611043af7bf416cc8458ee5bcb521a8c7668 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 15 Jun 2022 13:30:55 +0300 Subject: [PATCH] [#471] Add docker/* target in Makefile Allowed targets: - docker/all - docker/bin/neofs-s3-gw - docker/bin/neofs-authmate - docker/lint Signed-off-by: Alex Vanin --- .dockerignore | 1 + Makefile | 14 +++++++++++++- README.md | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index f4b11987f..09348a5e5 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,3 @@ .git +.cache .github diff --git a/Makefile b/Makefile index 6f58f82e8..76fb77ed5 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ # Common variables REPO ?= $(shell go list -m) VERSION ?= $(shell git describe --tags 2>/dev/null || cat VERSION 2>/dev/null || echo "develop") +GO_VERSION ?= 1.17 BINDIR = bin # Binaries to build @@ -14,7 +15,7 @@ REPO_BASENAME = $(shell basename `go list -m`) HUB_IMAGE ?= "nspccdev/$(REPO_BASENAME)" HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')" -.PHONY: help all dep clean format test cover lint docker/lint image-push image dirty-image +.PHONY: help all dep docker/ clean format test cover lint docker/lint image-push image dirty-image # Make all binaries all: $(BINS) @@ -39,6 +40,17 @@ dep: @CGO_ENABLED=0 \ go mod tidy -v && echo OK +docker/%: + $(if $(filter $*,all $(BINS)), \ + @echo "=> Running 'make $*' in clean Docker environment" && \ + docker run --rm -t \ + -v `pwd`:/src \ + -w /src \ + -u `stat -c "%u:%g" .` \ + --env HOME=/src \ + golang:$(GO_VERSION) make $*,\ + @echo "supported docker targets: all $(BINS) lint") + # Run tests test: @go test ./... -cover diff --git a/README.md b/README.md index 5ed91e362..8d7aaebdc 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,9 @@ NeoFS S3 gateway provides API compatible with Amazon S3 cloud storage service. Or you can call `make` to build it from the cloned repository (the binary will end up in `bin/neofs-s3-gw` with authmate helper in `bin/neofs-authmate`). +To build binaries in clean docker environment, call `make docker/all`. -Notable make targets: +Other notable make targets: ``` dep Check and ensure dependencies