From 100f5badb74bd300f026cd794b2818b72b816df0 Mon Sep 17 00:00:00 2001 From: Yann Soubeyrand Date: Tue, 23 Jul 2024 13:57:33 +0200 Subject: [PATCH] build: reduce Prometheus exporter binary size --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 881e319..756f164 100644 --- a/main.go +++ b/main.go @@ -110,7 +110,12 @@ func (prometheusExporter *VarnishPrometheusExporter) Binary( WithEnvVariable("GOOS", os). WithEnvVariable("GOARCH", arch). WithMountedDirectory(".", source.Tree()). - WithExec([]string{"go", "build", "-ldflags", fmt.Sprintf("-X 'main.Version=%s' -X 'main.VersionHash=%s' -X 'main.VersionDate=%s'", prometheusExporter.Version, commit, time.Now().Format("2006-01-02 15:04:05 -07:00"))}). + WithExec([]string{ + "go", "build", "-ldflags", "-s -w" + + fmt.Sprintf("-X 'main.Version=%s'", prometheusExporter.Version) + + fmt.Sprintf("-X 'main.VersionHash=%s'", commit) + + fmt.Sprintf("-X 'main.VersionDate=%s'", time.Now().Format("2006-01-02 15:04:05 -07:00")), + }). File("prometheus_varnish_exporter") return binary, nil