forked from iamseth/oracledb_exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
140 lines (110 loc) · 5.81 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
# ARCH ?= $(shell uname -m)
# GOARCH ?= $(subst x86_64,amd64,$(patsubst i%86,386,$(ARCH)))
GOARCH ?= $(shell go env GOARCH)
VERSION ?= $(strip $(subst v, , $(shell git describe --abbrev=0)))
MAJOR_VERSION ?= 21
MINOR_VERSION ?= 7
ORACLE_VERSION ?= $(MAJOR_VERSION).$(MINOR_VERSION)
PKG_VERSION ?= $(ORACLE_VERSION).0.0.0-1.el8.$(ARCH)
LDFLAGS := -X main.Version=$(VERSION)
GOFLAGS := -ldflags "$(LDFLAGS) -s -w"
RPM_VERSION ?= $(ORACLE_VERSION).0.0.0-1
ORA_RPM = oracle-instantclient-basic-$(PKG_VERSION).rpm oracle-instantclient-devel-$(PKG_VERSION).rpm
LD_LIBRARY_PATH = /usr/lib/oracle/$(ORACLE_VERSION)/client64/lib
BUILD_ARGS = --build-arg VERSION=$(VERSION) --build-arg ORACLE_VERSION=$(ORACLE_VERSION) \
--build-arg MAJOR_VERSION=$(MAJOR_VERSION)
LEGACY_TABLESPACE = --build-arg LEGACY_TABLESPACE=.legacy-tablespace
# DIST_DIR = oracledb_exporter.$(VERSION)-ora$(ORACLE_VERSION).linux-${GOARCH}
# ARCHIVE = oracledb_exporter.$(VERSION)-ora$(ORACLE_VERSION).linux-${GOARCH}.tar.gz
IMAGE_DOCKERHUB_NAME ?= lawyzheng1106/oracledb_exporter
IMAGE_NAME ?= registry.cn-hangzhou.aliyuncs.com/lawyzheng/oracledb_exporter
# export LD_LIBRARY_PATH ORACLE_VERSION
# %.rpm:
# wget -q https://download.oracle.com/otn_software/linux/instantclient/217000/$@
# download-rpms: $(ORA_RPM)
# prereq: download-rpms
# @echo deps
# sudo apt-get update
# sudo apt-get install --no-install-recommends -qq libaio1 rpm
# sudo rpm -Uvh --nodeps --force oracle*rpm
# echo $(LD_LIBRARY_PATH) | sudo tee /etc/ld.so.conf.d/oracle.conf
# sudo ldconfig
# oci.pc:
# sed "s/@ORACLE_VERSION@/$(ORACLE_VERSION)/g" oci8.pc.template | \
# sed "s/@MAJOR_VERSION@/$(MAJOR_VERSION)/g" > oci8.pc
build:
go build -o ./dist/oracledb_exporter && cp default-metrics.toml default-tlsconfig.yaml ./dist/
run: build
cd ./dist && ./oracledb_exporter
bin: clean linux-arm64 linux-amd64 windows-arm64 windows-amd64 darwin-arm64 darwin-amd64
darwin-%:
@echo build darwin
mkdir -p ./dist/oracledb_exporter.$(VERSION).darwin-$*
PKG_CONFIG_PATH=${PWD} GOARCH=$* GOOS=darwin go build $(GOFLAGS) -o ./dist/oracledb_exporter.$(VERSION).darwin-$*/oracledb_exporter
cp default-metrics.toml default-tlsconfig.yaml ./dist/oracledb_exporter.$(VERSION).darwin-$*
(cd dist ; zip -r oracledb_exporter.$(VERSION).darwin-$*.zip oracledb_exporter.$(VERSION).darwin-$*)
windows-%:
@echo build windows
mkdir -p ./dist/oracledb_exporter.$(VERSION).windows-$*
PKG_CONFIG_PATH=${PWD} GOARCH=$* GOOS=windows go build $(GOFLAGS) -o ./dist/oracledb_exporter.$(VERSION).windows-$*/oracledb_exporter.exe
cp default-metrics.toml default-tlsconfig.yaml ./dist/oracledb_exporter.$(VERSION).windows-$*
(cd dist ; zip -r oracledb_exporter.$(VERSION).windows-$*.zip oracledb_exporter.$(VERSION).windows-$*)
linux-%:
@echo build linux
mkdir -p ./dist/oracledb_exporter.$(VERSION).linux-$*
PKG_CONFIG_PATH=${PWD} GOARCH=$* GOOS=linux go build $(GOFLAGS) -o ./dist/oracledb_exporter.$(VERSION).linux-$*/oracledb_exporter
cp default-metrics.toml default-tlsconfig.yaml ./dist/oracledb_exporter.$(VERSION).linux-$*
(cd dist ; zip -r oracledb_exporter.$(VERSION).linux-$*.zip oracledb_exporter.$(VERSION).linux-$*)
darwin: darwin-${GOARCH}
linux: linux-${GOARCH}
windows: windows-${GOARCH}
deps:
@PKG_CONFIG_PATH=${PWD} go get
test:
@echo test
@PKG_CONFIG_PATH=${PWD} go test $$(go list ./... | grep -v /vendor/)
clean:
rm -rf ./dist sgerrand.rsa.pub glibc-2.29-r0.apk oci8.pc
ubuntu-image:
docker build -f Dockerfile.ubuntu $(BUILD_ARGS) -t "$(IMAGE_NAME):$(VERSION)" .
docker tag "$(IMAGE_NAME):$(VERSION)" "$(IMAGE_NAME):latest"
docker image prune --filter label=stage=oracleexporterbuilder -f
alpine-image:
docker build -f Dockerfile.alpine $(BUILD_ARGS) -t "$(IMAGE_NAME):$(VERSION)-alpine" .
docker tag "$(IMAGE_NAME):$(VERSION)-alpine" "$(IMAGE_NAME):alpine"
docker image prune --filter label=stage=oracleexporterbuilder -f
image: ubuntu-image alpine-image
push-images:
docker buildx build \
--platform linux/arm64,linux/amd64,linux/ppc64le,linux/arm/v7 \
-f Dockerfile.alpine $(BUILD_ARGS) \
-t "$(IMAGE_NAME):$(VERSION)-alpine" \
-t "$(IMAGE_NAME):alpine" \
-t "$(IMAGE_DOCKERHUB_NAME):$(VERSION)-alpine" \
-t "$(IMAGE_DOCKERHUB_NAME):alpine" . --push
docker buildx build \
--platform linux/arm64,linux/amd64,linux/ppc64le,linux/arm/v7 \
-f Dockerfile.ubuntu $(BUILD_ARGS) \
-t "$(IMAGE_NAME):$(VERSION)" \
-t "$(IMAGE_NAME):latest" \
-t "$(IMAGE_DOCKERHUB_NAME):$(VERSION)" \
-t "$(IMAGE_DOCKERHUB_NAME):latest" . --push
# sgerrand.rsa.pub:
# wget -q -O sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub
# glibc-2.29-r0.apk:
# wget -q -O glibc-2.29-r0.apk https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.29-r0/glibc-2.29-r0.apk
# oraclelinux-image:
# docker build -f oraclelinux/Dockerfile $(BUILD_ARGS) -t "$(IMAGE_NAME):$(VERSION)-oraclelinux" .
# docker build -f oraclelinux/Dockerfile $(BUILD_ARGS) $(LEGACY_TABLESPACE) -t "$(IMAGE_NAME):$(VERSION)-oraclelinux_legacy-tablespace" .
# docker tag "$(IMAGE_NAME):$(VERSION)-oraclelinux" "$(IMAGE_NAME):oraclelinux"
# ubuntu-image: $(ORA_RPM)
# docker build $(BUILD_ARGS) -t "$(IMAGE_NAME):$(VERSION)" .
# docker build $(BUILD_ARGS) $(LEGACY_TABLESPACE) -t "$(IMAGE_NAME):$(VERSION)_legacy-tablespace" .
# docker tag "$(IMAGE_NAME):$(VERSION)" "$(IMAGE_NAME):latest"
# alpine-image: $(ORA_RPM) sgerrand.rsa.pub glibc-2.29-r0.apk
# docker build -f alpine/Dockerfile $(BUILD_ARGS) -t "$(IMAGE_NAME):$(VERSION)-alpine" .
# docker build -f alpine/Dockerfile $(BUILD_ARGS) $(LEGACY_TABLESPACE) -t "$(IMAGE_NAME):$(VERSION)-alpine_legacy-tablespace" .
# docker tag "$(IMAGE_NAME):$(VERSION)-alpine" "$(IMAGE_NAME):alpine"
travis: oci.pc prereq deps test linux docker
@true
.PHONY: build deps test clean docker travis oci.pc