forked from pixie-io/pixie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
150 lines (117 loc) · 5.33 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# Makefile for the repo.
# This is used to help coordinate some of the tasks around the build process.
# Most of the actual build steps should be managed by Bazel.
## Bazel command to use.
BAZEL := bazel
## Dep command to use.
DEP := dep
## Minikube command to use.
MINIKUBE := minikube
## Kubectl command to use.
KUBECTL := kubectl
KUBECTL_FLAGS := -n pl
## Skaffold command to use.
SKAFFOLD := skaffold
## The directory to write template files to for skaffold (with respect to bazel info workspace).
SKAFFOLD_DIR := $$(bazel info workspace)/skaffold_build
## Active operating system (Linux vs MacOS).
UNAME_S := $(shell uname -s)
# Minikube flags to select vm-driver under MacOS
ifeq ($(UNAME_S),Darwin)
MINIKUBE_START_FLAGS += --vm-driver hyperkit
endif
.PHONY: clean
clean:
$(BAZEL) clean
rm -rf $(SKAFFOLD_DIR)
.PHONY: pristine
pristine:
$(BAZEL) clean --expunge
.PHONY: build
build: ## Run the full build (except UI).
$(BAZEL) build //...
.PHONY: test
test: ## Run all the tests (except UI).
$(BAZEL) test //... ${BAZEL_TEST_EXTRA_ARGS}
.PHONY: test-opt
test-opt: ## Run all the tests (except UI), optimized build.
$(BAZEL) test -c opt //... ${BAZEL_TEST_EXTRA_ARGS}
.PHONY: test-asan
test-asan: ## Run all the tests (except UI), with address sanitizer.
$(BAZEL) test --config=asan //... ${BAZEL_TEST_EXTRA_ARGS}
.PHONY: test-tsan
test-tsan: ## Run all the tests (except UI), with thread sanitizer.
$(BAZEL) test --config=tsan //... ${BAZEL_TEST_EXTRA_ARGS}
.PHONY: dep-ensure
dep-ensure: ## Ensure that go dependencies exist.
$(DEP) ensure
gazelle-repos: Gopkg.lock
$(BAZEL) run //:gazelle -- update-repos -from_file=Gopkg.lock
gazelle: gazelle-repos ## Run gazelle to update go build rules.
$(BAZEL) run //:gazelle
go-setup: dep-ensure gazelle
k8s-load-certs:
-$(KUBECTL) $(KUBECTL_FLAGS) delete secret proxy-tls-certs
-$(KUBECTL) $(KUBECTL_FLAGS) delete secret service-tls-certs
$(KUBECTL) $(KUBECTL_FLAGS) create secret tls proxy-tls-certs \
--key src/services/certs/server.key \
--cert src/services/certs/server.crt
$(KUBECTL) $(KUBECTL_FLAGS) create secret generic service-tls-certs \
--from-file=server.key=src/services/certs/server.key \
--from-file=server.crt=src/services/certs/server.crt \
--from-file=ca.crt=src/services/certs/ca.crt \
--from-file=client.key=src/services/certs/client.key \
--from-file=client.crt=src/services/certs/client.crt
k8s-load-dev-secrets: #Loads the secrets used by the dev environment. At some point it might makse sense to move this into a dev setup script somewhere.
-$(KUBECTL) $(KUBECTL_FLAGS) delete secret pl-app-secrets
$(KUBECTL) $(KUBECTL_FLAGS) create secret generic pl-app-secrets \
--from-literal=jwt-signing-key=ABCDEFG \
--from-literal=session-key=test-session-key \
--from-literal=auth0-client-id=qaAfEHQT7mRt6W0gMd9mcQwNANz9kRup \
--from-literal=auth0-client-secret=_rY9isTWtKgx2saBXNKZmzAf1y9pnKvlm-WdmSVZOFHb9OQtWHEX4Nrh3nWE5NNt
dev-env-start: ## Start dev environment.
$(MINIKUBE) start $(MINIKUBE_START_FLAGS) --cpus 6 --memory 8192 --mount-string="$(HOME):$(HOME)" --mount
$(MAKE) k8s-load-certs
$(MAKE) k8s-load-dev-secrets
dev-docker-start:
@eval $$(minikube docker-env); ./scripts/run_docker.sh --extra_args="$(DEV_DOCKER_EXTRA_ARGS)"
dev-env-stop: ## Stop dev environment.
$(MINIKUBE) stop
dev-env-teardown: dev-env-stop ## Clean up dev environment.
$(MINIKUBE) delete
skaffold-dev: ## Run Skaffold in the dev environment.
$(BAZEL) run //templates/skaffold:skaffoldtemplate -- --build_dir $(SKAFFOLD_DIR) --build_type dev
$(SKAFFOLD) dev -f $(SKAFFOLD_DIR)/skaffold/skaffold_dev.yaml
skaffold-prod: ## Run Skaffold in the prod environment.
$(BAZEL) run //templates/skaffold:skaffoldtemplate -- --build_dir $(SKAFFOLD_DIR) --build_type prod
$(SKAFFOLD) run -f $(SKAFFOLD_DIR)/skaffold/skaffold_prod.yaml
skaffold-staging: ## Run Skaffold in the staging environment.
$(BAZEL) run //templates/skaffold:skaffoldtemplate -- --build_dir $(SKAFFOLD_DIR) --build_type staging
$(SKAFFOLD) run -f $(SKAFFOLD_DIR)/skaffold/skaffold_staging.yaml
skaffold-nightly: ## Run Skaffold in the nightly environment.
$(BAZEL) run //templates/skaffold:skaffoldtemplate -- --build_dir $(SKAFFOLD_DIR) --build_type nightly
$(SKAFFOLD) run -f $(SKAFFOLD_DIR)/skaffold/skaffold_nightly.yaml
gen-jwt: ## Generate a JWT for our demo cluster.
@JWT=$$(PL_JWT_SIGNING_KEY=ABCDEFG $(BAZEL) run //src/utils/gen_test_key); \
echo ""; \
echo "Paste the following into your browser console:"; \
echo "pltoken='$$JWT';"; \
echo "localStorage.setItem('auth', JSON.stringify({'idToken':pltoken}));"
help: ## Print help for targets with comments.
@echo "Usage:"
@echo " make [target...] [VAR=foo VAR2=bar...]"
@echo ""
@echo "Useful commands:"
# Grab the comment prefixed with "##" after every rule.
@grep -Eh '^[a-zA-Z._-]+:.*?## .*$$' $(MAKEFILE_LIST) |\
sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(cyan)%-30s$(term-reset) %s\n", $$1, $$2}'
@echo ""
@echo "Useful variables:"
# Grab the comment prefixed with "##" before every variable.
@awk 'BEGIN { FS = ":=" } /^## /{x = substr($$0, 4); \
getline; if (NF >= 2) printf " $(cyan)%-30s$(term-reset) %s\n", $$1, x}' $(MAKEFILE_LIST) | sort
@echo ""
@echo "Typical usage:"
@printf " $(cyan)%s$(term-reset)\n %s\n\n" \
"make build" "Run a clean build and update all the GO deps." \
"make pristine" "Delete all cached builds." \