forked from infobloxopen/atlas-pubsub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
112 lines (84 loc) · 2.89 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
VERSION := $(shell git describe --dirty=-dirty --always)
APP_NAME := atlas.pubsub
# Absolute github repository name.
REPO := github.com/infobloxopen/atlas-pubsub
SRC = examples/server
# Source directory path relative to $GOPATH/src.
SRCDIR = $(REPO)/$(SRC)
# Output binary name.
BIN = pubsub
# Build directory absolute path.
BINDIR = $(CURDIR)/bin
# Utility docker image to generate Go files from .proto definition.
# https://github.com/infobloxopen/buildtool
BUILDTOOL_IMAGE := infoblox/buildtool:v2
DEFAULT_REGISTRY := infobloxcto
REGISTRY ?=$(DEFAULT_REGISTRY)
IMAGE_NAME := $(REGISTRY)/$(APP_NAME):$(VERSION)
IMAGE_NAME_PUB := $(REGISTRY)/$(APP_NAME)-pub:$(VERSION)
IMAGE_NAME_SUB := $(REGISTRY)/$(APP_NAME)-sub:$(VERSION)
default: build
build: fmt bin
GOOS=linux go build -o "$(BINDIR)/$(BIN)" "$(SRCDIR)"
# Builds example hello publisher and subscriber
build-example: fmt bin build
GOOS=linux go build -o "$(BINDIR)/$(BIN)-pub" "$(REPO)/examples/hello/publisher"
GOOS=linux go build -o "$(BINDIR)/$(BIN)-sub" "$(REPO)/examples/hello/subscriber"
# formats the repo
fmt:
@echo "Running 'go fmt ...'"
@go fmt -x "$(REPO)/..."
deps:
@echo "Getting dependencies..."
@dep ensure
bin:
mkdir -p "$(BINDIR)"
clean:
@rm -rf "$(BINDIR)"
@rm -rf .glide
# --- Docker commands ---
# Builds the docker image
image:
@docker build -t $(IMAGE_NAME) -f docker/Dockerfile .
# Builds the hello example images
image-example:
@docker build -t $(IMAGE_NAME_PUB) -f docker/Dockerfile.publisher .
@docker build -t $(IMAGE_NAME_SUB) -f docker/Dockerfile.subscriber .
# Pushes the image to docker
push: image
@docker push $(IMAGE_NAME)
# Pushes the hello example images to docker
push-example: image-example
@docker push $(IMAGE_NAME_PUB)
@docker push $(IMAGE_NAME_SUB)
# Runs the tests
test:
echo "" > coverage.txt
for d in `go list ./... | grep -v vendor`; do \
t=$$(date +%s); \
go test -v -coverprofile=cover.out -covermode=atomic $$d || exit 1; \
echo "Coverage test $$d took $$(($$(date +%s)-t)) seconds"; \
if [ -f cover.out ]; then \
cat cover.out >> coverage.txt; \
rm cover.out; \
fi; \
done
# --- Kuberenetes deployment ---
# Deploy the pubsub service in kubernetes
deploy-server:
@kubectl create -f deploy/pubsub.yaml
# Deployes the hello example publisher and subscriber
deploy-example:
@kubectl create -f deploy/pubsub-pub.yaml
@kubectl create -f deploy/pubsub-sub.yaml
# Removes the kubernetes pod
remove:
@kubectl delete -f deploy/pubsub.yaml
# Removes the example hello publisher and subscriber pods
remove-example:
@kubectl delete -f deploy/pubsub-pub.yaml
@kubectl delete -f deploy/pubsub-sub.yaml
vendor:
glide update -v
temp-create-pubsub:
cat pubsub.yaml | envsubst ' $AWS_ACCESS_KEY$AWS_ACCESS_KEY_ID$AWS_SECRET_ACCESS_KEY$AWS_SECRET_KEY'| ks create -f pubsub.yaml