Skip to content

Commit

Permalink
feat: multiarch docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
exfly committed Jan 10, 2024
1 parent c76acd4 commit 522598d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/.build
/.tarballs
pgpool2_exporter
pgpool2_exporter*
*.tar.gz
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
FROM quay.io/prometheus/busybox:latest
FROM --platform=$BUILDPLATFORM quay.io/prometheus/busybox:latest
LABEL maintainer="Bo Peng <[email protected]>"

ARG TARGETARCH

ENV POSTGRES_USERNAME postgres
ENV POSTGRES_PASSWORD postgres
ENV POSTGRES_DATABASE postgres
ENV PGPOOL_SERVICE localhost
ENV PGPOOL_SERVICE_PORT 9999
ENV SSLMODE disable

COPY pgpool2_exporter /bin/pgpool2_exporter
COPY pgpool2_exporter-$TARGETARCH /bin/pgpool2_exporter

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"]

Expand Down
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))

build: promu
@echo ">> building binaries"
export GOARCH=amd64
@$(PROMU) build --prefix $(PREFIX)
mv pgpool2_exporter pgpool2_exporter-amd64
GOARCH=arm64
@$(PROMU) build --prefix $(PREFIX)
mv pgpool2_exporter pgpool2_exporter-arm64

crossbuild: promu
@echo ">> building cross-platform binaries"
Expand All @@ -35,6 +40,6 @@ tarballs: crossbuild

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

.PHONY: promu build crossbuild tarball tarballs docker
1 change: 0 additions & 1 deletion pgpool2_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"fmt"
"math"
"net/url"
"os"
"regexp"
"strconv"
"sync"
Expand Down

0 comments on commit 522598d

Please sign in to comment.