-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
28 lines (22 loc) · 837 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
.DEFAULT_GOAL := build
BINARY=visual-search-backend
VERSION=$(shell git describe --abbrev=0 --tags 2> /dev/null || echo "0.1.0")
BUILD=$(shell git rev-parse HEAD 2> /dev/null || echo "undefined")
LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.Build=$(BUILD)"
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: build
build: ## Build
go build -o $(BINARY) $(LDFLAGS)
.PHONY: docker
docker: ## Build the docker image
docker build -t $(BINARY):latest -t $(BINARY):$(VERSION) \
--build-arg build=$(BUILD) --build-arg version=$(VERSION) \
-f Dockerfile --no-cache .
.PHONY: test
test: ## Run the test suite
go test ./...
.PHONY: clean
clean: ## Remove the binary
if [ -f $(BINARY) ] ; then rm $(BINARY) ; fi