Skip to content

Commit 96a222e

Browse files
committed
feat: multiarch docker image
1 parent c76acd4 commit 96a222e

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
/.build
22
/.tarballs
3-
pgpool2_exporter
3+
pgpool2_exporter*
44
*.tar.gz

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
FROM quay.io/prometheus/busybox:latest
1+
FROM --platform=$BUILDPLATFORM quay.io/prometheus/busybox:latest
22
LABEL maintainer="Bo Peng <pengbo@sraoss.co.jp>"
33

4+
ARG TARGETARCH
5+
46
ENV POSTGRES_USERNAME postgres
57
ENV POSTGRES_PASSWORD postgres
68
ENV POSTGRES_DATABASE postgres
79
ENV PGPOOL_SERVICE localhost
810
ENV PGPOOL_SERVICE_PORT 9999
911
ENV SSLMODE disable
1012

11-
COPY pgpool2_exporter /bin/pgpool2_exporter
13+
COPY pgpool2_exporter-$TARGETARCH /bin/pgpool2_exporter
1214

1315
CMD ["/bin/sh", "-c", "export DATA_SOURCE_USER=\"${POSTGRES_USERNAME}\" ; export DATA_SOURCE_PASS=\"${POSTGRES_PASSWORD}\" ; export DATA_SOURCE_URI=\"${PGPOOL_SERVICE}:${PGPOOL_SERVICE_PORT}/${POSTGRES_DATABASE}?sslmode=${SSLMODE}\" ; /bin/pgpool2_exporter"]
1416

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
GO := go
22
GOPATH := $(firstword $(subst :, ,$(shell $(GO) env GOPATH)))
3+
GOARCH ?= amd64
34

45
PROMU ?= $(GOPATH)/bin/promu
56
pkgs = $(shell $(GO) list ./... | grep -v /vendor/)
@@ -14,7 +15,8 @@ DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
1415

1516
build: promu
1617
@echo ">> building binaries"
17-
@$(PROMU) build --prefix $(PREFIX)
18+
@$(PROMU) build -v --prefix $(PREFIX)
19+
mv pgpool2_exporter pgpool2_exporter-$(GOARCH)
1820

1921
crossbuild: promu
2022
@echo ">> building cross-platform binaries"
@@ -35,6 +37,6 @@ tarballs: crossbuild
3537

3638
docker:
3739
@echo ">> building docker image"
38-
@docker build -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
40+
@docker buildx build --push --platform linux/amd64,linux/arm64 -t "$(DOCKER_REPO)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
3941

4042
.PHONY: promu build crossbuild tarball tarballs docker

pgpool2_exporter.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"fmt"
2929
"math"
3030
"net/url"
31-
"os"
3231
"regexp"
3332
"strconv"
3433
"sync"

0 commit comments

Comments
 (0)