forked from billimek/logspout
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
108 lines (90 loc) · 3.03 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
.PHONY: build
NAME=logspout
VERSION=$(shell cat VERSION)
# max image size of 40MB
MAX_IMAGE_SIZE := 40000000
ifeq ($(shell uname), Darwin)
XARGS_ARG="-L1"
endif
GOPACKAGES ?= $(shell go list ./... | egrep -v 'custom|vendor')
GOLINT := go list ./... | egrep -v '/custom/|/vendor/' | xargs $(XARGS_ARG) golint | egrep -v 'extpoints.go|types.go'
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:
test -x $(GOPATH)/bin/golint || go get github.com/golang/lint/golint
go get \
&& go install $(GOPACKAGES) \
&& go tool vet -v $(shell ls -d */ | egrep -v 'custom|vendor/' | xargs $(XARGS_ARG))
@if [ -n "$(shell $(GOLINT) | cut -d ':' -f 1)" ]; then $(GOLINT) && exit 1 ; fi
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-custom:
docker run --name $(NAME)-custom $(NAME):custom || true
docker logs $(NAME)-custom | 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