-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
88 lines (73 loc) · 1.97 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
NAME := personal-archive
VERSION := $(shell git describe | cut -c2-)
.PHONY: version
version:
@echo $(VERSION)
.PHONY: deps
deps:
@echo "\n\033[1;33m+ $@\033[0m"
@go mod download
.PHONY: deps-webui
deps-webui:
@echo "\n\033[1;33m+ $@\033[0m"
@cd webui && yarn install --pure-lockfile
.PHONY: run-local
run-local:
@echo "\n\033[1;33m+ $@\033[0m"
@ENV=local go run --tags "fts5" ./cmd/main.go
.PHONY: run-prod
run-prod:
@echo "\n\033[1;33m+ $@\033[0m"
@mkdir -p ~/.personal-archive
@docker run -td -v ~/.personal-archive:/data -p 1121:1121 --name $(NAME) lastiverse/$(NAME):$(VERSION)
.PHONY: run-webui
run-webui:
@echo "\n\033[1;33m+ $@\033[0m"
@cd webui && yarn start
.PHONY: build
build:
@echo "\n\033[1;33m+ $@\033[0m"
@env GOOS=linux GOARCH=amd64 CGO_ENABLED=1 go build --tags "fts5" -v $(GO_LDFLAGS) -o out/$(NAME) ./cmd/main.go
.PHONY: build-webui
build-webui:
@echo "\n\033[1;33m+ $@\033[0m"
@cd webui && yarn && yarn build
.PHONY: build-container
build-container: clean test
@echo "\n\033[1;33m+ $@\033[0m"
@docker build --build-arg VERSION=$(VERSION) -t lastiverse/$(NAME):$(VERSION) .
@docker tag lastiverse/$(NAME):$(VERSION) lastiverse/$(NAME):latest
.PHONY: push-container
push-container:
@echo "\n\033[1;33m+ $@\033[0m"
@docker push lastiverse/$(NAME):$(VERSION)
@docker push lastiverse/$(NAME):latest
.PHONY: tidy
tidy:
@echo "\n\033[1;33m+ $@\033[0m"
@go mod verify
@go mod tidy
@if ! git diff --quiet go.mod go.sum; then \
echo "please run go mod tidy and check in changes"; \
exit 1;\
fi
.PHONY: clean
clean:
@echo "\n\033[1;33m+ $@\033[0m"
@rm -f out/*
.PHONY: test
test:
@echo "\n\033[1;33m+ $@\033[0m"
@go test ./... --short
.PHONY: yarn-deduplicate
yarn-deduplicate:
@echo "\n\033[1;33m+ $@\033[0m"
@cd webui && yarn-deduplicate yarn.lock
.PHONY: gen
gen:
@echo "\n\033[1;33m+ $@\033[0m"
@if ! which mockgen >/dev/null; then \
echo "installing mockgen ..."; \
go install github.com/golang/mock/mockgen; \
fi
@go generate ./...