diff --git a/.goreleaser.yml b/.goreleaser.yml index d5d0d39f..280ad6be 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -4,6 +4,7 @@ builds: - binary: mongodb_exporter id: mongodb_exporter env: + - CGO_ENABLED=0 goos: - linux - darwin @@ -25,16 +26,12 @@ builds: id: mongodb_exporter-gssapi env: - CGO_ENABLED=1 + - CC=x86_64-linux-gnu-gcc + - CXX=x86_64-linux-gnu-g++ goos: - linux - - darwin - - windows goarch: - amd64 - - arm - - arm64 - goarm: - - 7 ignore: - goos: darwin goarch: arm diff --git a/Makefile b/Makefile index e19f35ec..edde3f4b 100644 --- a/Makefile +++ b/Makefile @@ -76,12 +76,12 @@ build: ## Build exporter binary using plain go build. build-gssapi: ## Build exporter binary with GSSAPI support (requires CGO enabled). CGO_ENABLED=1 go build -ldflags="$(GO_BUILD_LDFLAGS)" -tags gssapi -o $(PMM_RELEASE_PATH)/mongodb_exporter -release: ## Build the binaries using goreleaser - docker run --rm --privileged \ +release: ## Build and release the binaries using goreleaser + docker build -f goreleaser.Dockerfile -t percona/goreleaser . && docker run --rm --privileged \ -v ${PWD}:/go/src/github.com/user/repo \ -v /var/run/docker.sock:/var/run/docker.sock \ -w /go/src/github.com/user/repo \ - goreleaser/goreleaser release --snapshot --skip=publish --clean + percona/goreleaser release --snapshot --skip=publish --clean FILES = $(shell find . -type f -name '*.go' -not -path "./vendor/*") diff --git a/goreleaser.Dockerfile b/goreleaser.Dockerfile new file mode 100644 index 00000000..5a76da6d --- /dev/null +++ b/goreleaser.Dockerfile @@ -0,0 +1,27 @@ +# This is a custom goreleaser Dockerfile to help us prepare goreleaser images with kerberos libraries. +# That way, we can release mongodb_exporter binaries with support for GSSAPI authentication. +FROM golang:1.24-bookworm AS installer + +RUN go install github.com/goreleaser/goreleaser/v2@latest + +FROM golang:1.24-bookworm + +RUN apt-get update && apt-get install -y \ + git \ + make \ + bash \ + curl \ + docker.io \ + libkrb5-dev \ + gcc \ + gcc-x86-64-linux-gnu \ + libc6-dev \ + libc6-dev-amd64-cross \ + ca-certificates \ + build-essential \ + && rm -rf /var/lib/apt/lists/* + +RUN git config --global --add safe.directory '*' + +COPY --from=installer /go/bin/goreleaser /go/bin/goreleaser +ENTRYPOINT ["/go/bin/goreleaser"]