-
Notifications
You must be signed in to change notification settings - Fork 58
/
Makefile
79 lines (69 loc) · 1.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
NAME := cortex-tenant
MAINTAINER := Igor Novgorodov
DESCRIPTION := Cortex tenant proxy
URL := https://github.com/blind-oracle/cortex-tenant
LICENSE := MPL
VERSION := $(shell cat VERSION)
RELEASE := 1
GO ?= go
OUT := .out
all: rpm deb
build:
go test ./... && \
GOARCH=amd64 \
GOOS=linux \
$(GO) build -ldflags "-s -w -extldflags \"-static\" -X main.version=$(VERSION)"
prepare:
cd deploy && \
rm -rf $(OUT) && \
mkdir -p $(OUT)/etc $(OUT)/usr/sbin $(OUT)/var/lib/$(NAME) $(OUT)/usr/lib/systemd/system && \
cp $(NAME).yml $(OUT)/etc/$(NAME).yml && \
cp ../$(NAME) $(OUT)/usr/sbin
rpm: build prepare build-rpm
deb: build prepare build-deb
build-rpm:
cd deploy && \
mkdir -p $(OUT)/etc/sysconfig && \
cp $(NAME).env $(OUT)/etc/sysconfig/$(NAME) && \
cp $(NAME).rpm.service $(OUT)/usr/lib/systemd/system/$(NAME).service
fpm \
-s dir \
--config-files etc/$(NAME).yml \
--config-files etc/sysconfig/$(NAME) \
-C deploy/$(OUT)/ \
-t rpm \
--after-install deploy/after_install.sh \
-n $(NAME) \
-v $(VERSION) \
--iteration $(RELEASE) \
--force \
--rpm-compression bzip2 \
--rpm-os linux \
--url $(URL) \
--description "$(DESCRIPTION)" \
-m "$(MAINTAINER)" \
--license "$(LICENSE)" \
-a amd64 \
.
build-deb:
cd deploy && \
mkdir -p $(OUT)/etc/default && \
cp $(NAME).env $(OUT)/etc/default/$(NAME) && \
cp $(NAME).deb.service $(OUT)/usr/lib/systemd/system/$(NAME).service
fpm \
-s dir \
--config-files etc/$(NAME).yml \
--config-files etc/default/$(NAME) \
-C deploy/$(OUT)/ \
-t deb \
--after-install deploy/after_install.sh \
-n $(NAME) \
-v $(VERSION) \
--iteration $(RELEASE) \
--force \
--url $(URL) \
--description "$(DESCRIPTION)" \
-m "$(MAINTAINER)" \
--license "$(LICENSE)" \
-a amd64 \
.