generated from nyu-devops/project-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
81 lines (65 loc) · 2.53 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
# These can be overidden with env vars.
# Changes: All 1.0 replaced with latest. If there is an error try reverting this.
CLUSTER ?= nyu-devops
.PHONY: help
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-\\.]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: all
all: help
.PHONY: clean
clean: ## Removes all dangling docker images
$(info Removing all dangling docker images..)
docker image prune -f
.PHONY: venv
venv: ## Create a Python virtual environment
$(info Creating Python 3 virtual environment...)
python3 -m venv .venv
.PHONY: install
install: ## Install dependencies
$(info Installing dependencies...)
sudo python3 -m pip install --upgrade pip wheel
sudo pip install -r requirements.txt
.PHONY: lint
lint: ## Run the linter
$(info Running linting...)
flake8 service tests --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 service tests --count --max-complexity=10 --max-line-length=127 --statistics
pylint service tests --max-line-length=127
.PHONY: tests
test: ## Run the unit tests
$(info Running tests...)
green -vvv --processes=1 --run-coverage --termcolor --minimum-coverage=95
.PHONY: run
run: ## Run the service
$(info Starting service...)
honcho start
.PHONY: cluster
cluster: ## Create a K3D Kubernetes cluster with load balancer and registry
$(info Creating Kubernetes cluster with a registry and 1 node...)
k3d cluster create --agents 1 --registry-create cluster-registry:0.0.0.0:32000 --port '8080:80@loadbalancer'
.PHONY: cluster-rm
cluster-rm: ## Remove a K3D Kubernetes cluster
$(info Removing Kubernetes cluster...)
k3d cluster delete
.PHONY: login
login: ## Login to IBM Cloud using yur api key
$(info Logging into IBM Cloud cluster $(CLUSTER)...)
ibmcloud login -a cloud.ibm.com -g Default -r us-south --apikey @~/apikey.json
ibmcloud cr login
ibmcloud ks cluster config --cluster $(CLUSTER)
ibmcloud ks workers --cluster $(CLUSTER)
kubectl cluster-info
.PHONY: deploy
deploy: ## Deploy the service on local Kubernetes
$(info Deploying service locally...)
kubectl apply -f deploy/
.PHONY: build
build: ## Build image of the app
$(info Building image...)
docker build -t orders:latest .
docker tag orders:latest cluster-registry:32000/orders:latest
.PHONY: push
push: ## Push image to local registry
$(info Pushing image to local registry...)
docker push cluster-registry:32000/orders:latest
curl cluster-registry:32000/v2/_catalog