forked from envoyproxy/ratelimit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (70 loc) · 2.08 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
export GO111MODULE=on
PROJECT = ratelimit
REGISTRY ?= envoyproxy
IMAGE := $(REGISTRY)/$(PROJECT)
MODULE = github.com/envoyproxy/ratelimit
GIT_REF = $(shell git describe --tags || git rev-parse --short=8 --verify HEAD)
VERSION ?= $(GIT_REF)
SHELL := /bin/bash
.PHONY: bootstrap
bootstrap:
go get github.com/golang/mock/mockgen@v1.4.1
define REDIS_STUNNEL
cert = private.pem
pid = /var/run/stunnel.pid
[redis]
accept = 127.0.0.1:16381
connect = 127.0.0.1:6381
endef
define REDIS_PER_SECOND_STUNNEL
cert = private.pem
pid = /var/run/stunnel-2.pid
[redis]
accept = 127.0.0.1:16382
connect = 127.0.0.1:6382
endef
export REDIS_STUNNEL
export REDIS_PER_SECOND_STUNNEL
redis.conf:
echo "$$REDIS_STUNNEL" >> $@
redis-per-second.conf:
echo "$$REDIS_PER_SECOND_STUNNEL" >> $@
.PHONY: bootstrap_redis_tls
bootstrap_redis_tls: redis.conf redis-per-second.conf
openssl req -new -newkey rsa:4096 -days 365 -nodes -x509 \
-subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=localhost" \
-keyout key.pem -out cert.pem
cat key.pem cert.pem > private.pem
sudo cp cert.pem /usr/local/share/ca-certificates/redis-stunnel.crt
chmod 640 key.pem cert.pem private.pem
sudo update-ca-certificates
sudo stunnel redis.conf
sudo stunnel redis-per-second.conf
.PHONY: docs_format
docs_format:
script/docs_check_format
.PHONY: fix_format
fix_format:
script/docs_fix_format
go fmt $(MODULE)/...
.PHONY: check_format
check_format: docs_format
@gofmt -l $(shell go list -f '{{.Dir}}' ./...) | tee /dev/stderr | read && echo "Files failed gofmt" && exit 1 || true
.PHONY: compile
compile:
mkdir -p ./bin
go build -mod=readonly -o ./bin/ratelimit $(MODULE)/src/service_cmd
go build -mod=readonly -o ./bin/ratelimit_client $(MODULE)/src/client_cmd
go build -mod=readonly -o ./bin/ratelimit_config_check $(MODULE)/src/config_check_cmd
.PHONY: tests_unit
tests_unit: compile
go test -race $(MODULE)/...
.PHONY: tests
tests: compile
go test -race -tags=integration $(MODULE)/...
.PHONY: docker_image
docker_image: tests
docker build . -t $(IMAGE):$(VERSION)
.PHONY: docker_push
docker_push: docker_image
docker push $(IMAGE):$(VERSION)