-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
92 lines (69 loc) · 2.66 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
NAME=lion
BUILDDIR=build
VERSION ?= Unknown
BuildTime := $(shell date -u '+%Y-%m-%d %I:%M:%S%p')
COMMIT := $(shell git rev-parse HEAD)
GOVERSION := $(shell go version)
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
LDFLAGS=-w -s
GOLDFLAGS=-X 'main.Version=$(VERSION)'
GOLDFLAGS+=-X 'main.Buildstamp=$(BuildTime)'
GOLDFLAGS+=-X 'main.Githash=$(COMMIT)'
GOLDFLAGS+=-X 'main.Goversion=$(GOVERSION)'
GOBUILD=CGO_ENABLED=0 go build -trimpath -ldflags "$(GOLDFLAGS) ${LDFLAGS}"
UIDIR=ui
define make_artifact_full
GOOS=$(1) GOARCH=$(2) $(GOBUILD) -o $(BUILDDIR)/$(NAME)-$(1)-$(2)
mkdir -p $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/$(UIDIR)/dist/
cp $(BUILDDIR)/$(NAME)-$(1)-$(2) $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/$(NAME)
cp README.md $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/README.md
cp LICENSE $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/LICENSE
cp config_example.yml $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/config_example.yml
cp entrypoint.sh $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/entrypoint.sh
cp supervisord.conf $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/supervisord.conf
cp -r $(UIDIR)/dist/* $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2)/$(UIDIR)/dist/
cd $(BUILDDIR) && tar -czvf $(NAME)-$(VERSION)-$(1)-$(2).tar.gz $(NAME)-$(VERSION)-$(1)-$(2)
rm -rf $(BUILDDIR)/$(NAME)-$(VERSION)-$(1)-$(2) $(BUILDDIR)/$(NAME)-$(1)-$(2)
endef
build:
GOARCH=$(GOARCH) GOOS=$(GOOS) $(GO_BUILD) -o $(BUILDDIR)/$(NAME) .
all: lion-ui
$(call make_artifact_full,darwin,amd64)
$(call make_artifact_full,darwin,arm64)
$(call make_artifact_full,linux,amd64)
$(call make_artifact_full,linux,arm64)
$(call make_artifact_full,linux,mips64le)
$(call make_artifact_full,linux,ppc64le)
$(call make_artifact_full,linux,s390x)
$(call make_artifact_full,linux,riscv64)
$(call make_artifact_full,linux,loong64)
local: lion-ui
$(call make_artifact_full,$(shell go env GOOS),$(shell go env GOARCH))
darwin-amd64: lion-ui
$(call make_artifact_full,darwin,amd64)
darwin-arm64: lion-ui
$(call make_artifact_full,darwin,arm64)
linux-amd64: lion-ui
$(call make_artifact_full,linux,amd64)
linux-arm64: lion-ui
$(call make_artifact_full,linux,arm64)
linux-loong64: lion-ui
$(call make_artifact_full,linux,loong64)
linux-ppc64le: lion-ui
$(call make_artifact_full,linux,ppc64le)
linux-mips64le: lion-ui
$(call make_artifact_full,linux,mips64le)
linux-s390x: lion-ui
$(call make_artifact_full,linux,s390x)
linux-riscv64: lion-ui
$(call make_artifact_full,linux,riscv64)
.PHONY: docker
docker:
docker buildx build --build-arg VERSION=$(VERSION) -t jumpserver/lion:$(VERSION) .
lion-ui:
@echo "build ui"
@cd $(UIDIR) && yarn install && yarn build
clean:
rm -rf $(BUILDDIR)
-rm -rf $(UIDIR)/dist