-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
127 lines (89 loc) · 3.6 KB
/
Makefile
File metadata and controls
127 lines (89 loc) · 3.6 KB
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
123
124
125
126
127
CONTAINER_IMAGE = islavallee/librapi
CONTAINER_TAG ?= latest
GROUP_ID = $(shell id -g)
NAMESPACE = dev
RELEASE_NAME = librapi
USER_ID = $(shell id -u)
USERNAME = jenkins
DCAPI = docker-compose run --rm api
DCDEV = docker-compose -f docker-compose.dev.yml
DCHELM = docker-compose run --rm --user=$(USER_ID):$(GROUP_ID) -e HOME=/$(USERNAME) helm
.SILENT: ; # no need for @
.ONESHELL: ; # recipes execute in same shell
.NOTPARALLEL: ; # wait for this target to finish
.EXPORT_ALL_VARIABLES: ; # send all vars to shell
.PHONY: help
help: ## Show Help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
###############GAZR###############
init: ## Bootstrap your application.
docker-compose build
$(DCAPI) go mod download
style: go-lint ## Check lint.
style: helm-lint
complexity: ## Cyclomatic complexity check.
$(DCAPI) gocyclo .
format: ## Format code.
$(DCAPI) gofmt -w .
test: test-unit ## Shortcut to launch all the test tasks (unit, functional and integration).
test: test-functional
test: test-integration
test-unit: ## Launch unit tests.
$(DCAPI) go test -v ./...
test-functional: ## Launch functional tests. e.g behat, JBehave, Behave, CucumberJS, Cucumber etc...
echo "no functional tests"
test-integration: ## Launch integration tests. e.g. pytest, jest (js), phpunit, JUnit (java) etc ...
echo "no integration tests"
security-sast: ## launch static application security testing (SAST).
$(DCAPI) gosec ./...
run: ## Locally run the application.
docker run --rm -p 80:8080 $(CONTAINER_IMAGE):$(CONTAINER_TAG)
watch: dev-up ## Hot reloading for development.
buildd: ## Build the application.
docker build -t $(CONTAINER_IMAGE):$(CONTAINER_TAG) .
###############DEV###############
dev-build: ## DEV ENV - docker-compose build
$(DCDEV) build
dev-up: ## DEV ENV - docker-compose up
$(DCDEV) up -d
$(DCDEV) logs -f
dev-logs: ## DEV ENV - docker-compose logs
$(DCDEV) logs -f
dev-down: ## DEV ENV - docker-compose down
$(DCDEV) down
###############GO##############
go-lint: ## GO APP - Check lint on Go app.
$(DCAPI) golint ./...
###############HELM###############
helm-lint: ## HELM - Check lint on helm chart.
$(DCHELM) lint librapi/.
helm-template: ## HELM - Compile template
$(DCHELM) template librapi/.
helm-package: ## HELM - Build helm package
mkdir -p build/helm/
$(DCHELM) package librapi/. -d build/helm/
helm-install: ## HELM - Install app
helm install -n $(NAMESPACE) $(RELEASE_NAME) helm/librapi/.
helm-upgrade:
helm upgrade -n $(NAMESPACE) $(RELEASE_NAME) helm/librapi/.
helm-ls:
helm ls -n $(NAMESPACE)
helm-uninstall:
helm uninstall -n $(NAMESPACE) $(RELEASE_NAME)
###############MICROK8S###############
push-image: ## push local image to microk8s image cache
mkdir -p build/docker
docker save -o build/docker/librapi.tar ${CONTAINER_IMAGE}:${CONTAINER_TAG}
sudo microk8s ctr image import build/docker/librapi.tar
create-storage-class: ## Create the storage class in your microk8s cluster
kubectl apply -f helm/librapi/storageClass.yaml
create-namespace: ## Create the namespace in your microk8s cluster
kubectl create namespace $(NAMESPACE)
add-host: ## Add librapi.local to your /etc/hosts (you may need to enter your password)
grep -qxF '127.0.0.1 librapi.local' /etc/hosts || sudo sh -c "echo '127.0.0.1 librapi.local' >> /etc/hosts"
librapi-in-mk8s: buildd ## All in one command to start the app in a microk8s cluster
librapi-in-mk8s: push-image
librapi-in-mk8s: create-storage-class
librapi-in-mk8s: create-namespace
librapi-in-mk8s: helm-install
librapi-in-mk8s: add-host