-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·100 lines (70 loc) · 2.74 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
.PHONY: all clean install fmt version build run test
SHELL := /bin/sh
BASEDIR := $(shell echo $${PWD})
# build variables (provided to binaries by linker LDFLAGS below)
VERSION := 0.0.3
LDFLAGS=-ldflags "-X=main.Version=$(VERSION)"
# ignore vendor directory for go files
SRC := $(shell find . -type f -name '*.go' -not -path './vendor/*' -not -path './.git/*')
# for walking directory tree (like for proto rule)
DIRS = $(shell find . -type d -not -path '.' -not -path './vendor' -not -path './vendor/*' -not -path './.git' -not -path './.git/*')
# generated files that can be cleaned
GENERATED := $(shell find . -type f -name '*.pb.go' -not -path './vendor/*' -not -path './.git/*')
# ignore generated files when formatting/linting/vetting
CHECKSRC := $(shell find . -type f -name '*.go' -not -name '*.pb.go' -not -path './vendor/*' -not -path './.git/*')
OWNER := freignat91
NAME := mlearning
TAG := latest
IMAGE := $(OWNER)/$(NAME):$(TAG)
IMAGETEST := $(OWNER)/$(NAME):test
REPO := github.com/$(OWNER)/$(NAME)
CLI := ml
ENGINE := mlserver
TESTS := tests
all: version install
version:
@echo "version: $(VERSION) (build: $(BUILD))"
clean:
@rm -rf $(GENERATED)
install-cli:
@go install $(LDFLAGS) $(REPO)/$(CLI)
install-engine:
@go install $(LDFLAGS) $(REPO)/$(ENGINE)
install: install-cli install-engine
# format and simplify if possible (https://golang.org/cmd/gofmt/#hdr-The_simplify_command)
fmt:
@gofmt -s -l -w $(CHECKSRC)
proto:
@protoc mlserver/server/server.proto --go_out=plugins=grpc:.
run: build
test:
@go test ./tests -v
install-deps:
@glide install --strip-vcs --strip-vendor --update-vendored
update-deps:
@glide update --strip-vcs --strip-vendor --update-vendored
build: install-cli
@docker build -t $(IMAGE) .
buildtest: install-cli
@docker build -t $(IMAGETEST) .
start:
@docker node inspect self > /dev/null 2>&1 || docker swarm inspect > /dev/null 2>&1 || (echo "> Initializing swarm" && docker swarm init --advertise-addr 127.0.0.1)
@docker network ls | grep aNetwork || (echo "> Creating overlay network 'aNetwork'" && docker network create -d overlay aNetwork)
@docker service create --network aNetwork --name mlearning \
--publish 30107:30107 \
--detach=true \
--replicas=1 \
$(IMAGE)
starttest:
@docker node inspect self > /dev/null 2>&1 || docker swarm inspect > /dev/null 2>&1 || (echo "> Initializing swarm" && docker swarm init --advertise-addr 127.0.0.1)
@docker network ls | grep aNetwork || (echo "> Creating overlay network 'aNetwork'" && docker network create -d overlay aNetwork)
@docker service create --network aNetwork --name mlearning \
--publish 30107:30107 \
--detach=true \
--replicas=1 \
$(IMAGETEST)
stop:
@docker service rm mlearning || true
init:
@docker service rm mlearning || true
@rm -f ./logs/*