forked from dagu-org/dagu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
135 lines (99 loc) · 3.49 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
.PHONY: build server scheduler test proto certs swagger
########## Variables ##########
SRC_DIR=./
DST_DIR=$(SRC_DIR)/internal
BUILD_VERSION=$(shell date +'%y%m%d%H%M%S')
LDFLAGS=-X 'main.version=$(BUILD_VERSION)'
VERSION=
DOCKER_CMD := docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm64/v8 --builder container --build-arg VERSION=$(VERSION) --push --no-cache
DEV_CERT_SUBJ_CA="/C=TR/ST=ASIA/L=TOKYO/O=DEV/OU=DAGU/CN=*.dagu.dev/[email protected]"
DEV_CERT_SUBJ_SERVER="/C=TR/ST=ASIA/L=TOKYO/O=DEV/OU=SERVER/CN=*.server.dev/[email protected]"
DEV_CERT_SUBJ_CLIENT="/C=TR/ST=ASIA/L=TOKYO/O=DEV/OU=CLIENT/CN=*.client.dev/[email protected]"
DEV_CERT_SUBJ_ALT="subjectAltName=DNS:localhost"
########## Main Targets ##########
main:
go run . server
watch:
nodemon --watch . --ext go,gohtml --verbose --signal SIGINT --exec 'make server'
test:
@go test --race ./...
test-clean:
@go clean -testcache
@go test --race ./...
lint:
golangci-lint run -v
install-tools: install-nodemon install-swagger
swagger: clean-swagger gen-swagger
certs: cert-dir gencerts-ca gencerts-server gencerts-client gencert-check
build: build-ui build-dir go-lint build-bin
build-image: build-image-version build-image-latest
build-image-version:
ifeq ($(VERSION),)
$(error "VERSION is null")
endif
$(DOCKER_CMD) -t ghcr.io/dagu-dev/dagu:$(VERSION) .
build-image-latest:
$(DOCKER_CMD) -t ghcr.io/dagu-dev/dagu:latest .
server: go-lint build-dir build-bin
./bin/dagu server
https-server:
@DAGU_CERT_FILE=./cert/server-cert.pem \
DAGU_KEY_FILE=./cert/server-key.pem \
go run . server
scheduler: go-lint build-dir build-bin
./bin/dagu scheduler
########## Tools ##########
build-bin:
go build -ldflags="$(LDFLAGS)" -o ./bin/dagu .
build-dir:
@mkdir -p ./bin
build-ui:
@cd ui; \
yarn && yarn build
@rm -f ./service/frontend/assets/*.js
@rm -f ./service/frontend/assets/*.woff
@rm -f ./service/frontend/assets/*.woff2
@cp ui/dist/*.js ./service/frontend/assets/
@cp ui/dist/*.woff ./service/frontend/assets/
@cp ui/dist/*.woff2 ./service/frontend/assets/
go-lint:
@golangci-lint run ./...
cert-dir:
@mkdir -p ./cert
gencerts-ca:
@openssl req -x509 -newkey rsa:4096 \
-nodes -days 365 -keyout cert/ca-key.pem \
-out cert/ca-cert.pem \
-subj "$(DEV_CERT_SUBJ_CA)"
gencerts-server:
@openssl req -newkey rsa:4096 -nodes -keyout cert/server-key.pem \
-out cert/server-req.pem \
-subj "$(DEV_CERT_SUBJ_SERVER)"
@openssl x509 -req -in cert/server-req.pem -CA cert/ca-cert.pem -CAkey cert/ca-key.pem \
-CAcreateserial -out cert/server-cert.pem \
-extfile cert/openssl.conf
gencerts-client:
@openssl req -newkey rsa:4096 -nodes -keyout cert/client-key.pem \
-out cert/client-req.pem \
-subj "$(DEV_CERT_SUBJ_CLIENT)"
@openssl x509 -req -in cert/client-req.pem -days 60 -CA cert/ca-cert.pem \
-CAkey cert/ca-key.pem -CAcreateserial -out cert/client-cert.pem \
-extfile cert/openssl.conf
gencert-check:
@openssl x509 -in cert/server-cert.pem -noout -text
clean-swagger:
@echo "Cleaning files"
@rm -rf service/frontend/restapi/models
@rm -rf service/frontend/restapi/operations
gen-swagger:
@echo "Validating swagger yaml"
@swagger validate ./swagger.yaml
@echo "Generating swagger server code from yaml"
@swagger generate server -t service/frontend --server-package=restapi --exclude-main -f ./swagger.yaml
@echo "Running go mod tidy"
@go mod tidy
install-nodemon:
npm install -g nodemon
install-swagger:
brew tap go-swagger/go-swagger
brew install go-swagger