forked from BugRoger/nvidia-exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
31 lines (22 loc) · 752 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
DATE = $(shell date +%Y%m%d%H%M)
IMAGE ?= mrpk1906/nvidia-exporter
VERSION := $(DATE)
GOOS ?= $(shell go env | grep GOOS | cut -d'"' -f2)
BINARIES := nvidia-exporter
LDFLAGS := -X github.com/mrpk1906/nvidia-exporter/main.VERSION=$(VERSION)
GOFLAGS := -ldflags "$(LDFLAGS)"
SRCDIRS := .
PACKAGES := $(shell find $(SRCDIRS) -type d)
GOFILES := $(addsuffix /*.go,$(PACKAGES))
GOFILES := $(wildcard $(GOFILES))
.PHONY: all clean
all: $(BINARIES:%=bin/$(GOOS)/%)
bin/%: $(GOFILES) Makefile
GOOS=$(*D) GOARCH=amd64 go build $(GOFLAGS) -v -i -o $(@D)/$(@F) .
build:
docker build $(BUILD_ARGS) -t $(IMAGE):$(VERSION) -t $(IMAGE):latest .
push: build
docker push $(IMAGE):$(VERSION)
docker push $(IMAGE):latest
clean:
rm -rf bin/*