-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
72 lines (59 loc) · 2.37 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
###############################################################################
# The build architecture is select by setting the ARCH variable.
# For example: When building on ppc64le you could use ARCH=ppc64le make <....>.
# When ARCH is undefined it defaults to amd64.
ARCH?=$(shell go env GOARCH)
# Determine which OS.
OS?=$(shell go env GOOS)
PORT?=5000
# Get version from git.
GIT_VERSION?=$(shell git describe --tags --dirty)
SKILL_SERVER?=ollie-skill-server
CERT_DIR?=/tmp/$(SKILL_SERVER)
REGION?=ap
.PHONY: all binary clean help ssl-keys
default: help
## Make all targets
all: cmds
## Generate all cmds
cmds: $(SKILL_SERVER)
$(SKILL_SERVER):
$(MAKE) OS=$(OS) ARCH=$(ARCH) BINARY=$(SKILL_SERVER) binary
## Run API Server
run-api-server: $(SKILL_SERVER)
sudo ./dist/$(SKILL_SERVER)-$(OS)-$(ARCH) --port=$(PORT)
## Run ngrox proxy
run-ngrok:
ngrok http -bind-tls=true -host-header=rewrite --region=$(REGION) $(PORT)
ssl-keys:
mkdir -p $(CERT_DIR)
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout $(CERT_DIR)/dev.key -out $(CERT_DIR)/dev.crt \
-subj "/C=IN/ST=MH/L=Pune/CN=ollie-demo.io/emailAddress=sanket@infracloud.com"
binary:
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build -o dist/$(BINARY)-$(OS)-$(ARCH) \
-ldflags "-X main.VERSION=$(GIT_VERSION)" cmd/$(BINARY)/main.go
## Generate swagger code
swagger-codegen:
swagger generate server -f config/swagger/swagger.yaml -t ./pkg/
rm -r cmd
mv pkg/cmd .
## Cleanup all build files
clean:
rm -r dist
.PHONY: help
## Display this help text.
help: # Some kind of magic from https://gist.github.com/rcmachado/af3db315e31383502660
$(info Available targets)
@awk '/^[a-zA-Z\-\_0-9\/]+:/ { \
nb = sub( /^## /, "", helpMsg ); \
if(nb == 0) { \
helpMsg = $$0; \
nb = sub( /^[^:]*:.* ## /, "", helpMsg ); \
} \
if (nb) \
printf "\033[1;31m%-" width "s\033[0m %s\n", $$1, helpMsg; \
} \
{ helpMsg = $$0 }' \
width=20 \
$(MAKEFILE_LIST)