-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
82 lines (65 loc) · 3.19 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
.PHONY: clean-all clean-docker clean-kube build-site build-server build-docker build-all run-server run-docker run-hugo run-kube
#--- Variables ---
CURRDIR = `pwd`
EXTIP = `minikube ip`
USER = `whoami`
DOCKERREPO = `whoami`
KUBEFILES = .
#--- Help ---
help:
@echo
@echo Makefile targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@echo
#--- Clean up targets ---
clean-all: ## Removes the dist directory
rm -rf ./dist
clean-docker: ## Stops and removes all containers and images for apiscout
docker stop apiscout
docker rm apiscout
docker rmi retgits/apiscout
clean-kube: ## Removes the apiscout service and deployment from Kubernetes
kubectl delete svc apiscout-svc
kubectl delete deployment apiscout
#--- Get dependencies ---
deps: ## Get dependencies to build the server
go get -u github.com/TIBCOSoftware/apiscout/server
#--- Build targets ---
build-site: ## Builds the Hugo distribution in dist
mkdir -p dist
cp -r webapp/* ./dist
build-server: ## Builds the server app in dist
mkdir -p dist
cd server && go generate && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ../dist/server *.go
build-docker: ## Builds a docker image from the dist directory
cp Dockerfile ./dist/Dockerfile
cp -R ./nginx/ ./dist/nginx
eval $$(minikube docker-env) ;\
cd dist && docker image build . -t $(DOCKERREPO)/apiscout:latest
build-all: clean-all build-site build-server build-docker ## Performs clean-all and executes all build targets
#--- Run targets ---
run-server: ## Builds the in the server directory and runs it with default settings
cd server && go generate && GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ../dist/server *.go
MODE=LOCAL HUGODIR=$(CURRDIR)/webapp HUGOSTORE=$(CURRDIR)/webapp/content/apis SWAGGERSTORE=$(CURRDIR)/webapp/static/swaggerdocs EXTERNALIP=$(EXTIP) ./dist/server
run-docker: ## Runs a docker container with default settings
docker run -it --rm -p 80:80 -v $(HOME)/.kube:/root/.kube -v $(HOME)/.minikube:/home/$(USER)/.minikube -e MODE=LOCAL -e HUGODIR="/tmp" -e EXTERNALIP=$(EXTIP) -e HUGOCMD="sh -c \"cd /tmp && hugo\"" --name=apiscout $(DOCKERREPO)/apiscout:latest
run-hugo: ## Runs the embedded Hugo server on port 1313
cd webapp && hugo server -D --disableFastRender
run-docs: ## Runs the embedded Hugo server on port 1313 for the documentation
cd docs && hugo server -D --disableFastRender --themesDir ../webapp/themes
run-kube: ## Deploys apiscout to Kubernetes
kubectl apply -f ${KUBEFILES}/apiscout.yml
#--- Stop targets ---
stop-docker: ## Stop and remove the running apiscout container
docker stop apiscout && docker rm apiscout
#--- Minikube targets ---
minikube-install: ## Install Minikube on this machine
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 && chmod +x minikube && sudo cp minikube /usr/local/bin/ && rm minikube
minikube-start: ## Start Minikube with default configuration
minikube start
minikube-stop: ## Stop Minikube
minikube stop
minikube-delete: minikube-stop ## Delete the Minikube installation
minikube delete
minikube-show: ## Show the API Scout UI that is deployed to Minikube
open `minikube service apiscout-svc --url`