From 5baa2774d58a1b978261a146ca512c148803e164 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 7 Jun 2022 19:58:33 +0300 Subject: [PATCH] [#159] Add docker/$(BINS) target Use this target to build binaries in clean docker environment. Signed-off-by: Alex Vanin --- Makefile | 14 ++++++++++++-- README.md | 5 +++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 594ae55..319b6ec 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ REPO ?= $(shell go list -m) VERSION ?= $(shell git describe --tags --dirty --always) +GO_VERSION ?= 1.17 BUILD ?= $(shell date -u --iso=seconds) HUB_IMAGE ?= nspccdev/neofs-http-gw @@ -10,9 +11,9 @@ HUB_TAG ?= "$(shell echo ${VERSION} | sed 's/^v//')" # List of binaries to build. For now just one. BINDIR = bin DIRS = $(BINDIR) -BINS = "$(BINDIR)/neofs-http-gw" +BINS = $(BINDIR)/neofs-http-gw -.PHONY: help all dep clean fmts fmt imports test cover lint docker/lint +.PHONY: help all $(BINS) $(DIRS) docker/$(BINS) dep test cover fmts fmt imports image image-push dirty-image lint docker/lint version clean # Make all binaries all: $(BINS) @@ -29,6 +30,15 @@ $(DIRS): @echo "⇒ Ensure dir: $@" @mkdir -p $@ +docker/$(BINS): + @echo "=> Building binary using clean Docker environment" + @docker run --rm -t \ + -v `pwd`:/src \ + -w /src \ + -u "$$(id -u):$$(id -g)" \ + --env HOME=/src \ + golang:$(GO_VERSION) make $(BINS) + # Pull go dependencies dep: @printf "⇒ Download requirements: " diff --git a/README.md b/README.md index 94aa369..cbfa992 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,10 @@ NeoFS HTTP Gateway bridges NeoFS internal protocol and HTTP standard. ```go install github.com/nspcc-dev/neofs-http-gw``` Or you can call `make` to build it from the cloned repository (the binary will -end up in `bin/neofs-http-gw`). +end up in `bin/neofs-http-gw`). To build neofs-http-gw binary in clean docker +environment, call `make docker/bin/neofs-http-gw`. -Notable make targets: +Other notable make targets: ``` dep Check and ensure dependencies