-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
40 lines (29 loc) · 1.08 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
SHORT_NAME ?= vmdashboard
BUILD_DATE = $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
HASH = $(shell git describe --dirty --tags --always)
VERSION ?= unknown
REPO = github.com/fengxsong/aliyun-exporter
BUILD_PATH = cmd/dashboard/main.go
OUTPUT_PATH = build/_output/bin/$(SHORT_NAME)
LDFLAGS := -s -X github.com/prometheus/common/version.BuildDate=${BUILD_DATE} \
-X github.com/prometheus/common/version.Revision=${HASH} \
-X github.com/prometheus/common/version.Version=${VERSION}
IMAGE_REPO ?= fengxsong/${SHORT_NAME}
IMAGE_TAG ?= ${HASH}
IMAGE := ${IMAGE_REPO}:${IMAGE_TAG}
tidy:
go mod tidy
vendor: tidy
go mod vendor
bin:
CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags "${LDFLAGS}" -o ${OUTPUT_PATH} ${BUILD_PATH} || exit 1
linux-bin:
CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldflags "${LDFLAGS}" -o ${OUTPUT_PATH} ${BUILD_PATH} || exit 1
upx:
upx ${OUTPUT_PATH}
# Build the docker image
docker-build:
docker build --rm --build-arg=LDFLAGS="${LDFLAGS}" -t ${IMAGE} -t ${IMAGE_REPO}:latest -f Dockerfile .
# Push the docker image
docker-push:
docker push ${IMAGE}