forked from krakend/krakend-ce
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
150 lines (128 loc) · 5.02 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
.PHONY: all build test
# This Makefile is a simple example that demonstrates usual steps to build a binary that can be run in the same
# architecture that was compiled in. The "ldflags" in the build assure that any needed dependency is included in the
# binary and no external dependencies are needed to run the service.
BIN_NAME :=krakend
OS := $(shell uname | tr '[:upper:]' '[:lower:]')
VERSION := 1.4.1
PKGNAME := krakend
LICENSE := Apache 2.0
VENDOR=
URL := http://krakend.io
RELEASE := 0
USER := krakend
ARCH := amd64
DESC := High performance API gateway. Aggregate, filter, manipulate and add middlewares
MAINTAINER := Daniel Ortiz <[email protected]>
DOCKER_WDIR := /tmp/fpm
DOCKER_FPM := devopsfaith/fpm
GOLANG_VERSION := 1.16.4
FPM_OPTS=-s dir -v $(VERSION) -n $(PKGNAME) \
--license "$(LICENSE)" \
--vendor "$(VENDOR)" \
--maintainer "$(MAINTAINER)" \
--architecture $(ARCH) \
--url "$(URL)" \
--description "$(DESC)" \
--config-files etc/ \
--verbose
DEB_OPTS= -t deb --deb-user $(USER) \
--depends ca-certificates \
--before-remove builder/scripts/prerm.deb \
--after-remove builder/scripts/postrm.deb \
--before-install builder/scripts/preinst.deb
RPM_OPTS =--rpm-user $(USER) \
--before-install builder/scripts/preinst.rpm \
--before-remove builder/scripts/prerm.rpm \
--after-remove builder/scripts/postrm.rpm
DEBNAME=${PKGNAME}_${VERSION}-${RELEASE}_${ARCH}.deb
RPMNAME=${PKGNAME}-${VERSION}-${RELEASE}.x86_64.rpm
all: test
update_krakend_deps:
go get github.com/luraproject/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
# go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
go get github.com/devopsfaith/[email protected]
make test
build:
@echo "Building the binary..."
@go get .
@go build -ldflags="-X github.com/luraproject/lura/core.KrakendVersion=${VERSION}" -o ${BIN_NAME} ./cmd/krakend-ce
@echo "You can now use ./${BIN_NAME}"
test: build
go test -v ./tests
build_on_docker:
docker run --rm -it -v "${PWD}:/app" -w /app golang:${GOLANG_VERSION} make build
docker:
docker build --pull -t devopsfaith/krakend:${VERSION} .
builder/skel/%/etc/init.d/krakend: builder/files/krakend.init
mkdir -p "$(dir $@)"
cp builder/files/krakend.init "$@"
builder/skel/%/usr/bin/krakend: krakend
mkdir -p "$(dir $@)"
cp krakend "$@"
builder/skel/%/etc/krakend/krakend.json: krakend.json
mkdir -p "$(dir $@)"
cp krakend.json "$@"
builder/skel/%/lib/systemd/system/krakend.service: builder/files/krakend.service
mkdir -p "$(dir $@)"
cp builder/files/krakend.service "$@"
builder/skel/%/usr/lib/systemd/system/krakend.service: builder/files/krakend.service
mkdir -p "$(dir $@)"
cp builder/files/krakend.service "$@"
.PHONE: tgz
tgz: builder/skel/tgz/usr/bin/krakend
tgz: builder/skel/tgz/etc/krakend/krakend.json
tgz: builder/skel/tgz/etc/init.d/krakend
tar zcvf krakend_${VERSION}_${ARCH}.tar.gz -C builder/skel/tgz/ .
.PHONY: deb
deb: builder/skel/deb/usr/bin/krakend
deb: builder/skel/deb/etc/krakend/krakend.json
docker run --rm -it -v "${PWD}:${DOCKER_WDIR}" -w ${DOCKER_WDIR} ${DOCKER_FPM}:deb -t deb ${DEB_OPTS} \
--iteration ${RELEASE} \
--deb-systemd builder/files/krakend.service \
-C builder/skel/deb \
${FPM_OPTS}
.PHONY: rpm
rpm: builder/skel/rpm/usr/lib/systemd/system/krakend.service
rpm: builder/skel/rpm/usr/bin/krakend
rpm: builder/skel/rpm/etc/krakend/krakend.json
docker run --rm -it -v "${PWD}:${DOCKER_WDIR}" -w ${DOCKER_WDIR} ${DOCKER_FPM}:rpm -t rpm ${RPM_OPTS} \
--iteration ${RELEASE} \
-C builder/skel/rpm \
${FPM_OPTS}
.PHONY: clean
clean:
rm -rf builder/skel/*
rm -f *.deb
rm -f *.rpm
rm -f *.tar.gz
rm -f krakend
rm -rf vendor/