-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
125 lines (90 loc) · 3.9 KB
/
Copy pathMakefile
File metadata and controls
125 lines (90 loc) · 3.9 KB
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
export PATH := /usr/local/go/bin:$(PATH)
export GOPRIVATE := github.com/RakuenSoftware/*
export GONOSUMDB := github.com/RakuenSoftware/*
export GIT_CONFIG_COUNT := 1
export GIT_CONFIG_KEY_0 := url.git@github.com:.insteadOf
export GIT_CONFIG_VALUE_0 := https://github.com/
.PHONY: all build build-backend build-frontend build-runtime build-backend-low build-frontend-low \
build-low iso iso-low kernel kernel-low zfs zfs-low smoothkernel-low \
test test-backend test-frontend lint lint-backend clean install install-runtime deploy deploy-runtime
all: build
# --- Build ---
build: build-backend build-frontend
VERSION ?= $(shell date -u +%Y.%m%d.%H%M)-$(shell git rev-parse --short HEAD)
DEB_ARCH ?= $(shell dpkg --print-architecture 2>/dev/null || echo amd64)
export DEB_ARCH
build-backend:
cd tierd && CGO_ENABLED=1 go build -ldflags "-X main.version=$(VERSION)" -o ../bin/tierd ./cmd/tierd/
build-frontend:
cd tierd-ui && npm install --prefer-offline && npm run build
build-runtime:
./scripts/build-smoothnas-runtime.sh
build-backend-low:
./scripts/low-impact-build.sh $(MAKE) build-backend
build-frontend-low:
./scripts/low-impact-build.sh $(MAKE) build-frontend
build-low: build-backend-low build-frontend-low
iso:
./iso/build-iso.sh $(VERSION)
iso-low:
./scripts/low-impact-build.sh ./iso/build-iso.sh $(VERSION)
smoothkernel-low:
./scripts/build-smoothkernel.sh $(TARGETS)
kernel:
./scripts/build-smoothkernel.sh kernel
kernel-low:
./scripts/build-smoothkernel.sh kernel
zfs:
./scripts/build-smoothkernel.sh zfs
zfs-low:
./scripts/build-smoothkernel.sh zfs
# --- Lint ---
lint: lint-backend lint-frontend
lint-backend:
cd tierd && CGO_ENABLED=1 go vet ./...
lint-frontend:
cd tierd-ui && npm run lint
# --- Test ---
test: test-backend test-frontend
test-backend:
cd tierd && CGO_ENABLED=1 go test ./... -count=1
test-frontend:
cd tierd-ui && npm test
# --- Install (for deployment) ---
install: build
install -m 755 bin/tierd /usr/local/bin/tierd
mkdir -p /usr/share/tierd-ui
cp -r tierd-ui/dist/smoothnas-ui/* /usr/share/tierd-ui/
install -m 644 tierd/deploy/tierd-host-init.service /etc/systemd/system/tierd-host-init.service
install -m 644 tierd/deploy/tierd.service /etc/systemd/system/tierd.service
install -m 644 tierd/deploy/nginx.conf /etc/nginx/sites-available/tierd
mkdir -p /etc/nginx/conf.d/plugins.d
ln -sf /etc/nginx/sites-available/tierd /etc/nginx/sites-enabled/tierd
rm -f /etc/nginx/sites-enabled/default
bash tierd/deploy/generate-tls.sh
systemctl daemon-reload
systemctl enable tierd.service
systemctl enable nginx.service
install-runtime: build-runtime
install -m 755 -D bin/docker-lxc-daemon /usr/lib/smoothnas/docker-lxc-daemon
install -m 644 runtime/smoothnas-runtime.service /etc/systemd/system/smoothnas-runtime.service
systemctl daemon-reload
systemctl enable smoothnas-runtime.service
# --- Remote deploy (dev shortcut) ---
# Usage: make deploy HOST=root@192.168.1.x
HOST ?= root@smoothnas
deploy: build
rsync -av --delete --rsync-path="sudo rsync" tierd-ui/dist/smoothnas-ui/ $(HOST):/usr/share/tierd-ui/
rsync -av --rsync-path="sudo rsync" bin/tierd $(HOST):/usr/local/bin/tierd
rsync -av --rsync-path="sudo rsync" tierd/deploy/tierd-host-init.service $(HOST):/etc/systemd/system/tierd-host-init.service
rsync -av --rsync-path="sudo rsync" tierd/deploy/tierd.service $(HOST):/etc/systemd/system/tierd.service
ssh -t $(HOST) 'sudo systemctl daemon-reload && sudo systemctl restart tierd'
deploy-runtime: build-runtime
ssh -t $(HOST) 'sudo install -d -m 755 /usr/lib/smoothnas'
rsync -av --rsync-path="sudo rsync" bin/docker-lxc-daemon $(HOST):/usr/lib/smoothnas/docker-lxc-daemon
rsync -av --rsync-path="sudo rsync" runtime/smoothnas-runtime.service $(HOST):/etc/systemd/system/smoothnas-runtime.service
ssh -t $(HOST) 'sudo systemctl daemon-reload && sudo systemctl enable --now smoothnas-runtime.service'
# --- Clean ---
clean:
rm -rf bin/ tierd-ui/dist/
cd tierd && go clean