-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
39 lines (31 loc) · 878 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
29
30
31
32
33
34
35
36
37
38
39
# Project parameters
BINARY_NAME ?= signalilo
BINARY_VERSION = $(shell git describe --tags --always --dirty --match=v* || (echo "command failed $$?"; exit 1))
VERSION ?= $(BINARY_VERSION)
IMAGE_NAME ?= docker.io/vshn/$(BINARY_NAME):$(VERSION)
# Go parameters
GOCMD ?= go
GOBUILD ?= $(GOCMD) build
GOCLEAN ?= $(GOCMD) clean
GOTEST ?= $(GOCMD) test
GOGET ?= $(GOCMD) get
.PHONY: all
all: test build
.PHONY: build
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -v \
-o $(BINARY_NAME) \
-ldflags "-w -s -X main.Version=$(VERSION) -X 'main.BuildDate=$(shell date -Iseconds)'"
@echo built '$(VERSION)'
.PHONY: test
test:
$(GOTEST) -v -cover ./...
.PHONY: clean
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -rf $(web_dir)
.PHONY: docker
docker:
docker build --build-arg BINARY_VERSION=$(BINARY_VERSION) -t $(IMAGE_NAME) .
@echo built image $(IMAGE_NAME)