forked from bleenco/abstruse
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (58 loc) · 3.56 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
ABSTRUSE_UI_VERSION=$(shell cat web/abstruse/package.json | grep version | head -1 | awk -F: '{ print $$2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]')
ABSTRUSE_VERSION_PATH=github.com/bleenco/abstruse/internal/version
ifndef GIT_COMMIT
GIT_COMMIT=$(shell git rev-list -1 HEAD)
endif
BUILD_DATE=$(shell date +%FT%T%z)
CGO_ENABLED=1
all: build
build: build_ui statik protoc wire server worker
release:
@CGO_ENABLED=${CGO_ENABLED} gox -osarch="darwin/amd64 linux/amd64 linux/arm linux/386" -ldflags "-X ${ABSTRUSE_VERSION_PATH}.GitCommit=${GIT_COMMIT} -X ${ABSTRUSE_VERSION_PATH}.UIVersion=${ABSTRUSE_UI_VERSION} -X ${ABSTRUSE_VERSION_PATH}.BuildDate=${BUILD_DATE}" -output build/{{.Dir}}_{{.OS}}_{{.Arch}} ./cmd/abstruse-server
@CGO_ENABLED=${CGO_ENABLED} gox -osarch="darwin/amd64 linux/amd64 linux/arm linux/386" -ldflags "-X ${ABSTRUSE_VERSION_PATH}.GitCommit=${GIT_COMMIT} -X ${ABSTRUSE_VERSION_PATH}.UIVersion=${ABSTRUSE_UI_VERSION} -X ${ABSTRUSE_VERSION_PATH}.BuildDate=${BUILD_DATE}" -output build/{{.Dir}}_{{.OS}}_{{.Arch}} ./cmd/abstruse-worker
server:
@CGO_ENABLED=${CGO_ENABLED} go build -ldflags "-X ${ABSTRUSE_VERSION_PATH}.GitCommit=${GIT_COMMIT} -X ${ABSTRUSE_VERSION_PATH}.UIVersion=${ABSTRUSE_UI_VERSION} -X ${ABSTRUSE_VERSION_PATH}.BuildDate=${BUILD_DATE}" -o build/abstruse-server ./cmd/abstruse-server
worker:
@CGO_ENABLED=${CGO_ENABLED} go build -ldflags "-X ${ABSTRUSE_VERSION_PATH}.GitCommit=${GIT_COMMIT} -X ${ABSTRUSE_VERSION_PATH}.UIVersion=${ABSTRUSE_UI_VERSION} -X ${ABSTRUSE_VERSION_PATH}.BuildDate=${BUILD_DATE}" -o build/abstruse-worker ./cmd/abstruse-worker
build_ui:
@if [ ! -d "web/abstruse/dist" ]; then cd web/abstruse && npm run build; fi
statik:
@if [ ! -r "server/ui/statik.go" ]; then statik -dest ./server -p ui -src ./web/abstruse/dist; fi
wire:
@wire ./server/cmd/... ./worker/cmd/...
install_dependencies:
@go get google.golang.org/protobuf/cmd/protoc-gen-go
@go get github.com/jkuri/statik
@go get github.com/google/wire/cmd/[email protected]
@go get github.com/cespare/reflex
@go get google.golang.org/grpc/cmd/protoc-gen-go-grpc
@go install google.golang.org/protobuf/cmd/protoc-gen-go
@go install github.com/jkuri/statik
@go install github.com/google/wire/...
@go install github.com/cespare/reflex
@go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
@go mod tidy
@cd web/abstruse && npm install
clean:
@rm -rf build/ web/abstruse/dist server/ui/ server/cmd/wire_gen.go worker/cmd/wire_gen.go pb/api.pb.go pb/api_grpc.pb.go
dev:
@reflex -sr '\.go$$' -R '^web/' -R '^server/ui' -R '^worker/' -R '^configs/' -R '^tests/' -- sh -c 'make server && ./build/abstruse-server --logger-level debug'
dev_worker:
@reflex -sr '\.go$$' -R '^web/' -R '^server/' -R '^configs/' -R '^tests/' -- sh -c 'make worker && ./build/abstruse-worker --logger-level debug'
protoc:
@protoc ./pb/api.proto --go-grpc_out=. --go-grpc_opt=paths=source_relative --go_out=. --go_opt=paths=source_relative
docker: docker_server docker_worker
docker_server:
@docker build --rm --force-rm --compress --build-arg GIT_COMMIT=${GIT_COMMIT} -t abstruse/abstruse-server -f Dockerfile .
docker_worker:
@docker build --rm --force-rm --compress --build-arg GIT_COMMIT=${GIT_COMMIT} -t abstruse/abstruse-worker -f Dockerfile.worker .
docker_push:
@docker push abstruse/abstruse-server
@docker push abstruse/abstruse-worker
test:
go test -v ./...
test-unit:
cd web/abstruse && npm run test:ci
test-e2e:
go run ./tests/e2e
.PHONY: build server worker build_ui statik wire install_dependencies clean dev dev_worker protoc docker docker_server docker_worker docker_push test test-unit test-e2e release