-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
38 lines (30 loc) · 899 Bytes
/
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
# Makefile
# Deprecated: GH Workflow encouraged
BINARY="kibana_exporter"
IMG="kibana-prometheus-exporter"
TARGET="build"
VERSION="latest"
# explicitly go mod
export GO111MODULE=on
LDFLAGS=-ldflags "-extldflags '-static' -s -w"
.DEFAULT_GOAL: $(BINARY)
$(BINARY): clean
mkdir -p ${TARGET}
go fmt ./...
go test -v ./...
go build -o ${TARGET}/${BINARY}
chmod +x ${TARGET}/${BINARY}
release: clean
mkdir -p ${TARGET}/release
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -a -o ${TARGET}/release/${BINARY}-${VERSION}-linux-amd64
chmod -R +x ${TARGET}/release
test: $(BINARY)
test -d tmp
cp ${TARGET}/${BINARY} tmp/
docker: clean release
docker build --build-arg OS=linux --build-arg ARCH=amd64 --build-arg VERSION=${VERSION} -t chamilad/${IMG}:${VERSION} .
docker-release: clean release docker
docker push chamilad/${IMG}:${VERSION}
clean:
go clean
rm -rf ${TARGET}