Skip to content

Commit 442ae72

Browse files
committed
rework goreleaser for dynamic builds
1 parent 7c34685 commit 442ae72

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

.goreleaser.yml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ builds:
44
- binary: mongodb_exporter
55
id: mongodb_exporter
66
env:
7+
- CGO_ENABLED=0
78
goos:
89
- linux
910
- darwin
@@ -25,16 +26,12 @@ builds:
2526
id: mongodb_exporter-gssapi
2627
env:
2728
- CGO_ENABLED=1
29+
- CC=x86_64-linux-gnu-gcc
30+
- CXX=x86_64-linux-gnu-g++
2831
goos:
2932
- linux
30-
- darwin
31-
- windows
3233
goarch:
3334
- amd64
34-
- arm
35-
- arm64
36-
goarm:
37-
- 7
3835
ignore:
3936
- goos: darwin
4037
goarch: arm

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ build: ## Build exporter binary using plain go build.
7676
build-gssapi: ## Build exporter binary with GSSAPI support (requires CGO enabled).
7777
CGO_ENABLED=1 go build -ldflags="$(GO_BUILD_LDFLAGS)" -tags gssapi -o $(PMM_RELEASE_PATH)/mongodb_exporter
7878

79-
release: ## Build the binaries using goreleaser
80-
docker run --rm --privileged \
79+
release: ## Build and release the binaries using goreleaser
80+
docker build -f goreleaser.Dockerfile -t percona/goreleaser . && docker run --rm --privileged \
8181
-v ${PWD}:/go/src/github.com/user/repo \
8282
-v /var/run/docker.sock:/var/run/docker.sock \
8383
-w /go/src/github.com/user/repo \
84-
goreleaser/goreleaser release --snapshot --skip=publish --clean
84+
percona/goreleaser release --snapshot --skip=publish --clean
8585

8686
FILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
8787

goreleaser.Dockerfile

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This is a custom goreleaser Dockerfile to help us prepare goreleaser images with kerberos libraries.
2+
# That way, we can release mongodb_exporter binaries with support for GSSAPI authentication.
3+
FROM golang:1.24-bookworm AS installer
4+
5+
RUN go install github.com/goreleaser/goreleaser/v2@latest
6+
7+
FROM golang:1.24-bookworm
8+
9+
RUN apt-get update && apt-get install -y \
10+
git \
11+
make \
12+
bash \
13+
curl \
14+
docker.io \
15+
libkrb5-dev \
16+
gcc \
17+
gcc-x86-64-linux-gnu \
18+
libc6-dev \
19+
libc6-dev-amd64-cross \
20+
ca-certificates \
21+
build-essential \
22+
&& rm -rf /var/lib/apt/lists/*
23+
24+
#RUN git config --global --add safe.directory '*'
25+
#RUN git config --global url."https://".insteadOf git://
26+
27+
COPY --from=installer /go/bin/goreleaser /go/bin/goreleaser
28+
ENTRYPOINT ["/go/bin/goreleaser"]

0 commit comments

Comments
 (0)