Skip to content

Commit

Permalink
build: reduce Prometheus exporter binary size
Browse files Browse the repository at this point in the history
  • Loading branch information
yann-soubeyrand committed Jul 23, 2024
1 parent a40612e commit 100f5ba
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 100f5ba

Please sign in to comment.