-
Notifications
You must be signed in to change notification settings - Fork 399
/
Makefile
103 lines (84 loc) · 2.64 KB
/
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
TAG ?= latest
REGISTRY ?= acs
DOCKER ?= docker
SED_I ?= sed -i
GOHOSTOS ?= $(shell go env GOHOSTOS)
ifeq ($(GOHOSTOS),darwin)
SED_I=sed -i ''
endif
REPO_INFO=$(shell git config --get remote.origin.url)
ifndef GIT_COMMIT
GIT_COMMIT := git-$(shell git rev-parse --short HEAD)
endif
PKG = github.com/AliyunContainerService/log-pilot
ARCH ?= $(shell go env GOARCH)
GOARCH = ${ARCH}
DUMB_ARCH = ${ARCH}
GOBUILD_FLAGS :=
ALL_ARCH = amd64
BUSTED_ARGS =-v --pattern=_test
IMGNAME = log-pilot
IMAGE = $(REGISTRY)/$(IMGNAME)
#MULTI_ARCH_IMG = $(IMAGE)-$(ARCH)
MULTI_ARCH_IMG = $(IMAGE)
TEMP_DIR := $(shell mktemp -d)
DEF_VARS:=ARCH=$(ARCH) \
TAG=$(TAG) \
PKG=$(PKG) \
GOARCH=$(GOARCH) \
GIT_COMMIT=$(GIT_COMMIT) \
REPO_INFO=$(REPO_INFO) \
PWD=$(PWD)
.PHONY: container
container: clean-container .container-$(ARCH)
.PHONY: .container-$(ARCH)
.container-$(ARCH):
@echo "+ Copying artifact to temporary directory"
mkdir -p $(TEMP_DIR)/
cp -RP ./* $(TEMP_DIR)/
@echo "+ Building container image $(MULTI_ARCH_IMG)-filebeat:$(TAG)"
$(DOCKER) build --no-cache --pull -t $(MULTI_ARCH_IMG)-filebeat:$(TAG) -f Dockerfile.filebeat $(TEMP_DIR)/
ifeq ($(ARCH), amd64)
$(DOCKER) tag $(MULTI_ARCH_IMG)-filebeat:$(TAG) $(IMAGE)-filebeat:$(TAG)
$(DOCKER) tag $(MULTI_ARCH_IMG)-filebeat:$(TAG) $(IMGNAME):$(TAG)
endif
@echo "+ Building container image $(MULTI_ARCH_IMG)-fluentd:$(TAG)"
$(DOCKER) build --no-cache --pull -t $(MULTI_ARCH_IMG)-fluentd:$(TAG) -f Dockerfile.fluentd $(TEMP_DIR)/
ifeq ($(ARCH), amd64)
$(DOCKER) tag $(MULTI_ARCH_IMG)-fluentd:$(TAG) $(IMAGE)-fluentd:$(TAG)
endif
.PHONY: clean-container
clean-container:
@echo "+ Deleting container image $(MULTI_ARCH_IMG):$(TAG)"
$(DOCKER) rmi -f $(MULTI_ARCH_IMG)-filebeat:$(TAG) || true
$(DOCKER) rmi -f $(MULTI_ARCH_IMG)-fluentd:$(TAG) || true
.PHONY: static-check
static-check:
@$(DEF_VARS) \
build/static-check.sh
.PHONY: test
test:
@$(DEF_VARS) \
build/test.sh
.PHONY: vet
vet:
@go vet $(shell go list ${PKG}/... | grep -v vendor)
.PHONY: check_dead_links
check_dead_links:
docker run -t \
-v $$PWD:/tmp aledbf/awesome_bot:0.1 \
--allow-dupe \
--allow-redirect $(shell find $$PWD -mindepth 1 -name "*.md" -printf '%P\n' | grep -v vendor | grep -v Changelog.md)
.PHONY: dep-ensure
dep-ensure:
dep version || curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure -v
dep prune -v
find vendor -name '*_test.go' -delete
.PHONY: misspell
misspell:
@go get github.com/client9/misspell/cmd/misspell
misspell \
-locale US \
-error \
main.go assets/* build/* docs/* examples/* hack/* pilot/* quickstart/* README.md