Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 929e27b

Browse files
authored
👷 Merge docker build + push step (#380)
* 👷 Merge docker build + push step * ✏️ Fix ide warning * 🔖 Bump to 0.5.2 * 👷 Handle build with podman * 🚨 Fix linter warning
1 parent 814c959 commit 929e27b

File tree

6 files changed

+108
-89
lines changed

6 files changed

+108
-89
lines changed

.github/workflows/pull-request.yml

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ jobs:
191191
with:
192192
ref: ${{ env.PULL_REQUEST_HEAD }}
193193

194+
- name: Log in to registry
195+
if: ${{ env.FORKED == 'false' }}
196+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ${{ env.REGISTRY }} -u $ --password-stdin
197+
194198
- name: Build image
195199
id: docker-meta
196200
env:
@@ -200,16 +204,6 @@ jobs:
200204
TAG_SUFFIX=$(echo "-${{ matrix.name }}" | sed s/-ubuntu//)
201205
echo "image-id=$IMAGE_NAME" >> $GITHUB_OUTPUT
202206
echo "image-version=${VERSION}${TAG_SUFFIX}" >> $GITHUB_OUTPUT
203-
204-
- name: Log in to registry
205-
if: ${{ env.FORKED == 'false' }}
206-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ${{ env.REGISTRY }} -u $ --password-stdin
207-
208-
- name: Push image
209-
if: ${{ env.FORKED == 'false' }}
210-
env:
211-
VERSION: "${{ needs.release.outputs.version }}"
212-
run: |
213207
make push-${{ matrix.name }}-image
214208
215209
- name: Format current time

.github/workflows/release.yml

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ jobs:
131131
- name: Checkout
132132
uses: actions/checkout@v3
133133

134-
- name: Set releasw version
134+
- name: Set release version
135135
id: version
136136
run: echo "version=${{ needs.build.outputs.version }}" >> $GITHUB_OUTPUT
137137

@@ -173,6 +173,9 @@ jobs:
173173
- name: Checkout
174174
uses: actions/checkout@v3
175175

176+
- name: Log in to registry
177+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ${{ env.REGISTRY }} -u $ --password-stdin
178+
176179
- name: Build image
177180
id: docker-meta
178181
env:
@@ -182,14 +185,6 @@ jobs:
182185
TAG_SUFFIX=$(echo "-${{ matrix.name }}" | sed s/-ubuntu//)
183186
echo "image-id=$IMAGE_NAME" >> $GITHUB_OUTPUT
184187
echo "image-version=${VERSION}${TAG_SUFFIX}" >> $GITHUB_OUTPUT
185-
186-
- name: Log in to registry
187-
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ${{ env.REGISTRY }} -u $ --password-stdin
188-
189-
- name: Push image
190-
env:
191-
VERSION: "${{ needs.release.outputs.version }}"
192-
run: |
193188
make push-${{ matrix.name }}-image
194189
195190
- name: Setup cosign
@@ -210,7 +205,7 @@ jobs:
210205
run: make sign-${{ matrix.name }}-image
211206

212207
- name: Container scan
213-
uses: aquasecurity/trivy-action@0.8.0
208+
uses: aquasecurity/trivy-action@0.14.0
214209
env:
215210
image-ref: "${{ steps.docker-meta.outputs.image-id }}:${{ steps.docker-meta.outputs.image-version }}"
216211
with:

Makefile

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@ OS_TYPE ?= $(shell uname -s | tr '[:upper:]' '[:lower:]')
33
ARCH_TYPE ?= $(subst x86_64,amd64,$(patsubst i%86,386,$(ARCH)))
44
GOOS ?= $(shell go env GOOS)
55
GOARCH ?= $(shell go env GOARCH)
6-
VERSION ?= 0.5.1
6+
VERSION ?= 0.5.2
77
LDFLAGS := -X main.Version=$(VERSION)
88
GOFLAGS := -ldflags "$(LDFLAGS) -s -w"
99
BUILD_ARGS = --build-arg VERSION=$(VERSION)
1010
LEGACY_TABLESPACE = --build-arg LEGACY_TABLESPACE=.legacy-tablespace
1111
OUTDIR = ./dist
12+
LINTER_VERSION ?= v1.55.2
13+
LINTER_IMAGE ?= docker.io/golangci/golangci-lint:$(LINTER_VERSION)
14+
15+
ifeq ($(shell command -v podman 2> /dev/null),)
16+
DOCKER_CMD = docker
17+
else
18+
DOCKER_CMD = podman
19+
endif
1220

1321
IMAGE_NAME ?= iamseth/oracledb_exporter
1422
IMAGE_ID ?= $(IMAGE_NAME):$(VERSION)
@@ -64,7 +72,9 @@ go-build-windows-x86:
6472

6573
go-lint:
6674
@echo "Linting codebase"
67-
docker run --rm -v $(shell pwd):/app -v ~/.cache/golangci-lint/v1.50.1:/root/.cache -w /app golangci/golangci-lint:v1.50.1 golangci-lint run -v
75+
mkdir -p ~/.cache/golangci-lint/$(LINTER_VERSION)
76+
$(DOCKER_CMD) run --rm -v $$PWD:/app -v ~/.cache/golangci-lint/$(LINTER_VERSION):/root/.cache -w /app \
77+
$(LINTER_IMAGE) golangci-lint run -v
6878

6979
local-build: go-build
7080
@true
@@ -90,19 +100,19 @@ push-images:
90100
@make --no-print-directory push-alpine-image
91101

92102
oraclelinux-image:
93-
if DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect "$(IMAGE_ID)-oraclelinux" > /dev/null; then \
103+
if DOCKER_CLI_EXPERIMENTAL=enabled $(DOCKER_CMD) manifest inspect "$(IMAGE_ID)-oraclelinux" > /dev/null; then \
94104
echo "Image \"$(IMAGE_ID)-oraclelinux\" already exists on ghcr.io"; \
95105
else \
96-
docker build --progress=plain $(BUILD_ARGS) -t "$(IMAGE_ID)-oraclelinux" --build-arg BASE_IMAGE=$(ORACLE_LINUX_BASE_IMAGE) . && \
97-
docker build --progress=plain $(BUILD_ARGS) $(LEGACY_TABLESPACE) -t "$(IMAGE_ID)-oraclelinux_legacy-tablespace" --build-arg BASE_IMAGE=$(ORACLE_LINUX_BASE_IMAGE) . && \
98-
docker tag "$(IMAGE_ID)-oraclelinux" "$(IMAGE_NAME):oraclelinux"; \
106+
$(DOCKER_CMD) build --progress=plain $(BUILD_ARGS) -t "$(IMAGE_ID)-oraclelinux" --build-arg BASE_IMAGE=$(ORACLE_LINUX_BASE_IMAGE) . && \
107+
$(DOCKER_CMD) build --progress=plain $(BUILD_ARGS) $(LEGACY_TABLESPACE) -t "$(IMAGE_ID)-oraclelinux_legacy-tablespace" --build-arg BASE_IMAGE=$(ORACLE_LINUX_BASE_IMAGE) . && \
108+
$(DOCKER_CMD) tag "$(IMAGE_ID)-oraclelinux" "$(IMAGE_NAME):oraclelinux"; \
99109
fi
100110

101111
push-oraclelinux-image:
102-
docker push $(IMAGE_ID)-oraclelinux
112+
$(DOCKER_CMD) push $(IMAGE_ID)-oraclelinux
103113
ifeq ("$(RELEASE)", "true")
104-
docker push "$(IMAGE_NAME):oraclelinux"
105-
docker push "$(IMAGE_ID)-oraclelinux_legacy-tablespace"
114+
$(DOCKER_CMD) push "$(IMAGE_NAME):oraclelinux"
115+
$(DOCKER_CMD) push "$(IMAGE_ID)-oraclelinux_legacy-tablespace"
106116
endif
107117

108118
sign-oraclelinux-image:
@@ -113,19 +123,19 @@ else
113123
endif
114124

115125
ubuntu-image:
116-
if DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect "$(IMAGE_ID)" > /dev/null; then \
126+
if DOCKER_CLI_EXPERIMENTAL=enabled $(DOCKER_CMD) manifest inspect "$(IMAGE_ID)" > /dev/null; then \
117127
echo "Image \"$(IMAGE_ID)\" already exists on ghcr.io"; \
118128
else \
119-
docker build --progress=plain $(BUILD_ARGS) --build-arg BASE_IMAGE=$(UBUNTU_BASE_IMAGE) -t "$(IMAGE_ID)" . && \
120-
docker build --progress=plain $(BUILD_ARGS) --build-arg BASE_IMAGE=$(UBUNTU_BASE_IMAGE) $(LEGACY_TABLESPACE) -t "$(IMAGE_ID)_legacy-tablespace" . && \
121-
docker tag "$(IMAGE_ID)" "$(IMAGE_ID_LATEST)"; \
129+
$(DOCKER_CMD) build --progress=plain $(BUILD_ARGS) --build-arg BASE_IMAGE=$(UBUNTU_BASE_IMAGE) -t "$(IMAGE_ID)" . && \
130+
$(DOCKER_CMD) build --progress=plain $(BUILD_ARGS) --build-arg BASE_IMAGE=$(UBUNTU_BASE_IMAGE) $(LEGACY_TABLESPACE) -t "$(IMAGE_ID)_legacy-tablespace" . && \
131+
$(DOCKER_CMD) tag "$(IMAGE_ID)" "$(IMAGE_ID_LATEST)"; \
122132
fi
123133

124134
push-ubuntu-image:
125-
docker push $(IMAGE_ID)
135+
$(DOCKER_CMD) push $(IMAGE_ID)
126136
ifeq ("$(RELEASE)", "true")
127-
docker push "$(IMAGE_ID_LATEST)"
128-
docker push "$(IMAGE_ID)_legacy-tablespace"
137+
$(DOCKER_CMD) push "$(IMAGE_ID_LATEST)"
138+
$(DOCKER_CMD) push "$(IMAGE_ID)_legacy-tablespace"
129139
endif
130140

131141
sign-ubuntu-image:
@@ -137,18 +147,18 @@ else
137147
endif
138148

139149
alpine-image:
140-
if DOCKER_CLI_EXPERIMENTAL=enabled docker manifest inspect "$(IMAGE_ID)-alpine" > /dev/null; then \
150+
if DOCKER_CLI_EXPERIMENTAL=enabled $(DOCKER_CMD) manifest inspect "$(IMAGE_ID)-alpine" > /dev/null; then \
141151
echo "Image \"$(IMAGE_ID)-alpine\" already exists on ghcr.io"; \
142152
else \
143-
docker build --progress=plain $(BUILD_ARGS) -t "$(IMAGE_ID)-alpine" --build-arg BASE_IMAGE=$(ALPINE_BASE_IMAGE) . && \
144-
docker build --progress=plain $(BUILD_ARGS) $(LEGACY_TABLESPACE) --build-arg BASE_IMAGE=$(ALPINE_BASE_IMAGE) -t "$(IMAGE_ID)-alpine_legacy-tablespace" . && \
145-
docker tag "$(IMAGE_ID)-alpine" "$(IMAGE_NAME):alpine"; \
153+
$(DOCKER_CMD) build --progress=plain $(BUILD_ARGS) -t "$(IMAGE_ID)-alpine" --build-arg BASE_IMAGE=$(ALPINE_BASE_IMAGE) . && \
154+
$(DOCKER_CMD) build --progress=plain $(BUILD_ARGS) $(LEGACY_TABLESPACE) --build-arg BASE_IMAGE=$(ALPINE_BASE_IMAGE) -t "$(IMAGE_ID)-alpine_legacy-tablespace" . && \
155+
$(DOCKER_CMD) tag "$(IMAGE_ID)-alpine" "$(IMAGE_NAME):alpine"; \
146156
fi
147157

148158
push-alpine-image:
149-
docker push $(IMAGE_ID)-alpine
159+
$(DOCKER_CMD) push $(IMAGE_ID)-alpine
150160
ifeq ("$(RELEASE)", "true")
151-
docker push "$(IMAGE_NAME):alpine"
161+
$(DOCKER_CMD) push "$(IMAGE_NAME):alpine"
152162
endif
153163

154164
sign-alpine-image:

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
[Troubleshooting](#troubleshooting)
1414
[Operating principles](operating-principles.md)
1515

16-
# Description
16+
## Description
1717

1818
A [Prometheus](https://prometheus.io/) exporter for Oracle modeled after the MySQL exporter. I'm not a DBA or seasoned Go developer so PRs definitely welcomed.
1919

@@ -45,11 +45,11 @@ The following metrics are exposed currently.
4545
- oracledb_resource_current_utilization
4646
- oracledb_resource_limit_value
4747

48-
# Installation
48+
## Installation
4949

50-
## Docker
50+
### Docker / Podman
5151

52-
You can run via Docker using an existing image. Since version 0.4, the images are available on the github registry.
52+
You can run via Docker/Podman using an existing image. Since version 0.4, the images are available on the github registry.
5353

5454
Here an example to retrieve the version 0.5.0:
5555

@@ -94,14 +94,14 @@ Manager. See https://github.com/iamseth/oracledb_exporter/issues/153 for
9494
details. The versions above should have a more useful tablespace utilization
9595
calculation going forward.
9696

97-
## Binary Release
97+
### Binary Release
9898

9999
Pre-compiled versions for Linux 64 bit and Mac OSX 64 bit can be found under [releases](https://github.com/iamseth/oracledb_exporter/releases).
100100

101101
In order to run, you'll need the [Oracle Instant Client Basic](http://www.oracle.com/technetwork/database/features/instant-client/index-097480.html)
102102
for your operating system. Only the basic version is required for execution.
103103

104-
## Running
104+
#### Running
105105
Ensure that the environment variable DATA_SOURCE_NAME is set correctly before starting.
106106
DATA_SOURCE_NAME should be in Oracle Database connection string format:
107107

@@ -154,7 +154,7 @@ v$session
154154
v$resource_limit
155155
```
156156

157-
# Integration with System D
157+
#### Integration with System D
158158

159159
Create `oracledb_exporter` user with disabled login and `oracledb_exporter` group then run the following commands:
160160

@@ -222,12 +222,12 @@ Usage of oracledb_exporter:
222222
Path to configuration file that can enable TLS or authentication.
223223
```
224224

225-
# Default metrics
225+
## Default metrics
226226

227227
This exporter comes with a set of default metrics defined in **default-metrics.toml**. You can modify this file or
228228
provide a different one using `default.metrics` option.
229229

230-
# Custom metrics
230+
### Custom metrics
231231

232232
> NOTE: Do not put a `;` at the end of your SQL queries as this will **NOT** work.
233233
@@ -331,7 +331,7 @@ COPY custom-metrics.toml /
331331
ENTRYPOINT ["/oracledb_exporter", "--custom.metrics", "/custom-metrics.toml"]
332332
```
333333

334-
# Using a multiple host data source name
334+
## Using a multiple host data source name
335335

336336
> NOTE: This has been tested with v0.2.6a and will most probably work on versions above.
337337
@@ -369,7 +369,7 @@ database =
369369
- `TNS_ADMIN`: Path you choose for the tns admin folder (`/path/to/tns_admin` in the example file above)
370370
- `DATA_SOURCE_NAME`: Datasource pointing to the `TNS_ENTRY` (`user:password@database` in the example file above)
371371

372-
# TLS connection to database
372+
## TLS connection to database
373373

374374
First, set the following variables:
375375

@@ -400,13 +400,13 @@ Here a complete example of string connection:
400400

401401
For more details, have a look at the following location: https://github.com/iamseth/oracledb_exporter/issues/84
402402

403-
# Integration with Grafana
403+
## Integration with Grafana
404404

405405
An example Grafana dashboard is available [here](https://grafana.com/grafana/dashboards/3333-oracledb/).
406406

407-
# Build
407+
## Build
408408

409-
## Docker build
409+
### Docker/Podman build
410410

411411
To build Ubuntu and Alpine image, run the following command:
412412

@@ -420,7 +420,7 @@ Or Alpine:
420420

421421
make alpine-image
422422

423-
## Building Binaries
423+
### Building Binaries
424424

425425
Run build:
426426

@@ -472,9 +472,9 @@ Here is a small snippet of an example usage of the exporter in code:
472472

473473
```
474474

475-
# FAQ/Troubleshooting
475+
## FAQ/Troubleshooting
476476

477-
## Unable to convert current value to float (metric=par,metri...in.go:285
477+
### Unable to convert current value to float (metric=par,metri...in.go:285
478478

479479
Oracle is trying to send a value that we cannot convert to float. This could be anything like 'UNLIMITED' or 'UNDEFINED' or 'WHATEVER'.
480480

@@ -492,11 +492,11 @@ If the value of limite_value is 'UNLIMITED', the request send back the value -1.
492492

493493
You can increase the log level (`--log.level debug`) in order to get the statement generating this error.
494494

495-
## error while loading shared libraries: libclntsh.so.xx.x: cannot open shared object file: No such file or directory
495+
### error while loading shared libraries: libclntsh.so.xx.x: cannot open shared object file: No such file or directory
496496

497497
Version before 0.5 use libs from Oracle in order to connect to Oracle Database. After 0.5 release, the oracle exporter use an pure Go DB driver and don't need binaries from Oracle anymore.
498498

499-
Please switch to version 0.5.
499+
**Please switch to version 0.5.**
500500

501501
For older version, you must install the Oracle binaries somewhere on your machine and **you must install the good version number**. If the
502502
error talk about the version 18.3, you **must** install 18.3 binary version. If it's 12.2, you **must** install 12.2.
@@ -508,7 +508,7 @@ Here an example to run this exporter (to scrap metrics from system/oracle@//host
508508

509509
`docker run -it --rm -p 9161:9161 -e DATA_SOURCE_NAME=oracle://system/oracle@//host:1521/service-or-sid iamseth/oracledb_exporter:0.2.6a`
510510

511-
## Error scraping for wait_time
511+
### Error scraping for wait_time
512512

513513
If you experience an error `Error scraping for wait_time: sql: Scan error on column index 1: converting driver.Value type string (",01") to a float64: invalid syntax source="main.go:144"` you may need to set the NLS_LANG variable.
514514

@@ -521,7 +521,7 @@ export DATA_SOURCE_NAME=system/oracle@myhost
521521

522522
If using Docker, set the same variable using the -e flag.
523523

524-
## An Oracle instance generates a lot of trace files being monitored by exporter
524+
### An Oracle instance generates a lot of trace files being monitored by exporter
525525

526526
As being said, Oracle instance may (and probably does) generate a lot of trace files alongside its alert log file, one trace file per scraping event. The trace file contains the following lines
527527

@@ -539,7 +539,7 @@ The root cause is Oracle's reaction of quering ASM-related views without ASM use
539539
$ find $ORACLE_BASE/diag/rdbms -name '*.tr[cm]' -mtime +14 -delete
540540
```
541541

542-
## TLS and basic authentication
542+
### TLS and basic authentication
543543

544544
Apache Exporter supports TLS and basic authentication. This enables better
545545
control of the various HTTP endpoints.
@@ -552,7 +552,7 @@ Note that the TLS and basic authentication settings affect all HTTP endpoints:
552552
/metrics for scraping, /probe for probing, and the web UI.
553553

554554

555-
## Multi-target support
555+
### Multi-target support
556556

557557
This exporter supports the multi-target pattern. This allows running a single instance of this exporter for multiple Oracle targets.
558558

0 commit comments

Comments
 (0)