-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
122 lines (92 loc) · 3.46 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
.PHONY: proto
SHELL = /bin/bash
IMAGES ?= orders products gateway
TAG ?= $(shell git rev-parse HEAD)
CONTEXT ?= docker-for-desktop
NAMESPACE ?= examples
DOCKER_HUB_ORG ?= nameko
install-dependencies:
pip install -U -e "orders/.[dev]"
pip install -U -e "products/.[dev]"
make -C gateway install
# Generate Proto
products-proto:
python -m grpc_tools.protoc \
--proto_path=proto \
--python_out=products/products \
--grpc_python_out=products/products \
products.proto
@# Hack untill I figure how to invoke this piece of code:
@# https://github.com/grpc/grpc/pull/10862/files
@sed -i.bak 's/^\(import.*_pb2\)/from . \1/' products/products/*grpc.py
@rm products/products/*.bak
orders-proto:
python -m grpc_tools.protoc \
--proto_path=proto \
--python_out=orders/orders \
--grpc_python_out=orders/orders \
orders.proto
@# Hack untill I figure how to invoke this piece of code:
@# https://github.com/grpc/grpc/pull/10862/files
@sed -i.bak 's/^\(import.*_pb2\)/from . \1/' orders/orders/*grpc.py
@rm orders/orders/*.bak
proto: products-proto orders-proto
# Run examples locally
# Relies on `nodemon` nodejs utility installed globally:
# `$ sudo npm install -g nodemon --unsafe-perm=true --allow-root`
develop-orders:
nodemon --ext py --watch orders/orders --watch orders/config.yaml \
--exec "nameko run --config orders/config.yaml orders.service"
develop-products:
nodemon --ext py --watch products/products --watch products/config.yaml --exec "nameko run --config products/config.yaml products.service"
develop-gateway:
make -C gateway develop
develop: proto
$(MAKE) -j3 develop-orders develop-products develop-gateway
# test
test:
rm .coverage || true
flake8 orders products
coverage run --append -m pytest orders/test $(ARGS)
coverage run --append -m pytest products/test $(ARGS)
coverage-report:
coverage report -m
coverage-html:
coverage html --fail-under 100
coverage: test coverage-report coverage-html
# docker
build-images: proto
for image in $(IMAGES) ; do TAG=$(TAG) DOCKER_HUB_ORG=$(DOCKER_HUB_ORG) make -C $$image build-image; done
push-images:
for image in $(IMAGES) ; do make -C $$image TAG=$(TAG) DOCKER_HUB_ORG=$(DOCKER_HUB_ORG) push-image; done
# Kubernetes
deploy-postgresql:
helm upgrade $(NAMESPACE)-postgresql stable/postgresql \
--install --namespace=$(NAMESPACE) --kube-context=$(CONTEXT) \
--set fullnameOverride=postgresql \
--set resources.requests.cpu=10m \
--set resources.requests.memory=50Mi \
--set readinessProbe.initialDelaySeconds=60 \
--set livenessProbe.initialDelaySeconds=60;
deploy-redis:
helm upgrade $(NAMESPACE)-redis stable/redis \
--install --namespace $(NAMESPACE) --kube-context=$(CONTEXT) \
--set fullnameOverride=redis \
--set cluster.enabled=false
deploy-rabbitmq:
helm upgrade $(NAMESPACE)-rabbitmq stable/rabbitmq-ha \
--install --namespace=$(NAMESPACE) --kube-context=$(CONTEXT) \
--set fullnameOverride=rabbitmq \
--set image.tag=3.7-management-alpine \
--set replicaCount=1 \
--set persistentVolume.enabled=true \
--set updateStrategy=RollingUpdate \
--set rabbitmqMemoryHighWatermarkType=relative \
--set rabbitmqMemoryHighWatermark=0.5
deploy-dependencies: deploy-postgresql deploy-redis deploy-rabbitmq
deploy-services:
for image in $(IMAGES) ; do TAG=$(TAG) DOCKER_HUB_ORG=$(DOCKER_HUB_ORG) make -C charts install-$$image; done
# https://www.telepresence.io
telepresence:
telepresence --context $(CONTEXT) \
--namespace $(NAMESPACE) --method vpn-tcp