-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathMakefile
50 lines (36 loc) · 1.41 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
# Version number
VERSION=$(shell ./tools/image-tag | cut -d, -f 1)
GIT_REVISION := $(shell git rev-parse --short HEAD)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
GOPATH := $(shell go env GOPATH)
GO_OPT= -mod vendor -ldflags "-X main.Branch=$(GIT_BRANCH) -X main.Revision=$(GIT_REVISION) -X main.Version=$(VERSION)"
### Development
.PHONY: run
run:
go run ./cmd/prometheus-plex-exporter
### Build
.PHONY: prometheus-plex-exporter
prometheus-plex-exporter:
CGO_ENABLED=0 go build $(GO_OPT) -o ./bin/$(GOOS)/prometheus-plex-exporter-$(GOARCH) ./cmd/prometheus-plex-exporter
.PHONY: exe
exe:
GOOS=linux $(MAKE) $(COMPONENT)
### Docker Images
.PHONY: docker-component # Not intended to be used directly
docker-component: check-component exe
docker build -t jsclayton/$(COMPONENT) --build-arg=TARGETARCH=$(GOARCH) -f ./cmd/$(COMPONENT)/Dockerfile .
docker tag jsclayton/$(COMPONENT) $(COMPONENT)
docker tag jsclayton/$(COMPONENT) ghcr.io/jsclayton/$(COMPONENT):latest
docker tag jsclayton/$(COMPONENT) ghcr.io/jsclayton/$(COMPONENT):main
.PHONY: docker-prometheus-plex-exporter
docker-prometheus-plex-exporter:
COMPONENT=prometheus-plex-exporter $(MAKE) docker-component
.PHONY: docker-images
docker-images: docker-prometheus-plex-exporter
.PHONY: check-component
check-component:
ifndef COMPONENT
$(error COMPONENT variable was not defined)
endif