-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
74 lines (62 loc) · 1.61 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
GOPKG ?= ultre.me/calcbiz
DOCKER_IMAGE ?= ultreme/calcbiz
GOBINS ?= ./cmd/calcbiz
RUN_OPTS ?=
PRE_INSTALL_STEPS += generate
PRE_UNITTEST_STEPS += generate
PRE_TEST_STEPS += generate
PRE_BUILD_STEPS += generate
PRE_LINT_STEPS += generate
PRE_TIDY_STEPS += generate
PRE_BUMPDDEPS_STEPS += generate
all: test install
include rules.mk
.PHONY: run
run: install
calcbiz server $(RUN_OPTS)
##
## generate
##
.PHONY: packr
packr:
packr
PROTOS_SRC := $(wildcard ./api/*.proto)
GEN_SRC := $(PROTOS_SRC) Makefile
.PHONY: generate
generate: gen.sum
gen.sum: $(GEN_SRC)
shasum $(GEN_SRC) | sort > gen.sum.tmp
diff -q gen.sum gen.sum.tmp || ( \
set -e; \
GO111MODULE=on go mod vendor; \
docker run \
--user=`id -u` \
--volume="$(PWD):/go/src/ultre.me/calcbiz" \
--workdir="/go/src/ultre.me/calcbiz" \
--entrypoint="sh" \
--rm \
pathwar/protoc:4 \
-xec 'make generate_local'; \
make tidy \
)
.PHONY: generate_local
generate_local:
@set -e; for proto in $(PROTOS_SRC); do ( set -xe; \
protoc -I ./vendor/github.com/grpc-ecosystem/grpc-gateway:./api:./vendor:/protobuf --grpc-gateway_out=logtostderr=true:"$(GOPATH)/src" --gogofaster_out="plugins=grpc:$(GOPATH)/src" "$$proto" \
); done
goimports -w ./pkg ./cmd ./internal
shasum $(GEN_SRC) | sort > gen.sum.tmp
mv gen.sum.tmp gen.sum
.PHONY: clean
clean:
rm -f gen.sum $(wildcard */*/*.pb.go */*/*.pb.gw.go)
##
## production
##
.PHONY: prod.up
prod.up:
docker-compose build --pull
docker-compose up -d --force-recreate --remove-orphans
.PHONY: deploy
deploy:
ssh zrwf.m.42.am -xec 'cd ~/go/src/ultre.me/calcbiz; git pull; make prod.up'