forked from gliderlabs/logspout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
131 lines (108 loc) · 3.57 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
.PHONY: build
NAME=logspout
VERSION=$(shell cat VERSION)
# max image size of 40MB
MAX_IMAGE_SIZE := 40000000
GOBIN := $(shell go env GOPATH | awk -F ":" '{ print $$1 }')/bin
GOLANGCI_LINT_VERSION := v1.18.0
ifeq ($(shell uname), Darwin)
XARGS_ARG="-L1"
endif
GOPACKAGES ?= $(shell go list ./... | egrep -v 'custom|vendor')
TEST_ARGS ?= -race
ifdef TEST_RUN
TESTRUN := -run ${TEST_RUN}
endif
build-dev:
docker build -f Dockerfile.dev -t $(NAME):dev .
dev: build-dev
@docker run --rm \
-e DEBUG=true \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(PWD):/go/src/github.com/gliderlabs/logspout \
-p 8000:80 \
-e ROUTE_URIS=$(ROUTE) \
$(NAME):dev
build:
mkdir -p build
docker build -t $(NAME):$(VERSION) .
docker save $(NAME):$(VERSION) | gzip -9 > build/$(NAME)_$(VERSION).tgz
build-custom:
docker tag $(NAME):$(VERSION) gliderlabs/$(NAME):master
cd custom && docker build -t $(NAME):custom .
lint-requirements:
ifeq ($(shell which golangci-lint), )
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(GOBIN) $(GOLANGCI_LINT_VERSION)
endif
lint: lint-requirements
$(GOBIN)/golangci-lint run
lint-ci-direct: lint-requirements
$(GOBIN)/golangci-lint --verbose run
lint-ci: build-dev
docker run \
-v $(PWD):/go/src/github.com/gliderlabs/logspout \
$(NAME):dev make -e lint-ci-direct
test: build-dev
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(PWD):/go/src/github.com/gliderlabs/logspout \
-e TEST_ARGS="" \
-e DEBUG=$(DEBUG) \
$(NAME):dev make -e test-direct
test-direct:
go test -p 1 -v $(TEST_ARGS) $(GOPACKAGES) $(TESTRUN)
test-image-size:
@if [ $(shell docker inspect -f '{{ .Size }}' $(NAME):$(VERSION)) -gt $(MAX_IMAGE_SIZE) ]; then \
echo ERROR: image size greater than $(MAX_IMAGE_SIZE); \
exit 2; \
fi
test-tls:
docker run -d --name $(NAME)-tls \
-v /var/run/docker.sock:/var/run/docker.sock \
$(NAME):$(VERSION) syslog+tls://logs3.papertrailapp.com:54202
sleep 2
docker logs $(NAME)-tls
docker inspect --format='{{ .State.Running }}' $(NAME)-tls | grep true
docker stop $(NAME)-tls || true
docker rm $(NAME)-tls || true
test-healthcheck:
docker run -d --name $(NAME)-healthcheck \
-p 8000:80 \
-v /var/run/docker.sock:/var/run/docker.sock \
$(NAME):$(VERSION)
sleep 5
docker logs $(NAME)-healthcheck
docker inspect --format='{{ .State.Running }}' $(NAME)-healthcheck | grep true
curl --head --silent localhost:8000/health | grep "200 OK"
docker stop $(NAME)-healthcheck || true
docker rm $(NAME)-healthcheck || true
test-custom:
docker run --name $(NAME)-custom $(NAME):custom || true
docker logs $(NAME)-custom 2>&1 | grep -q logstash
docker rmi gliderlabs/$(NAME):master || true
docker rm $(NAME)-custom || true
test-tls-custom:
docker run -d --name $(NAME)-tls-custom \
-v /var/run/docker.sock:/var/run/docker.sock \
$(NAME):custom syslog+tls://logs3.papertrailapp.com:54202
sleep 2
docker logs $(NAME)-tls-custom
docker inspect --format='{{ .State.Running }}' $(NAME)-tls-custom | grep true
docker stop $(NAME)-tls-custom || true
docker rm $(NAME)-tls-custom || true
release:
rm -rf release && mkdir release
go get github.com/progrium/gh-release/...
cp build/* release
gh-release create gliderlabs/$(NAME) $(VERSION) \
$(shell git rev-parse --abbrev-ref HEAD) $(VERSION)
circleci:
ifneq ($(CIRCLE_BRANCH), release)
echo build-$$CIRCLE_BUILD_NUM > VERSION
endif
clean:
rm -rf build/
docker rm $(shell docker ps -aq) || true
docker rmi $(NAME):dev $(NAME):$(VERSION) || true
docker rmi $(shell docker images -f 'dangling=true' -q) || true
.PHONY: release clean