Skip to content

Commit

Permalink
Optimize binaries (#21)
Browse files Browse the repository at this point in the history
Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
  • Loading branch information
jpkrohling authored Oct 30, 2020
1 parent 2a20919 commit c725aab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ builds:
- flags:
- -trimpath
ldflags:
- -s -w -X github.com/observatorium/opentelemetry-collector-builder/cmd.version={{.Version}} -X github.com/observatorium/opentelemetry-collector-builder/cmd.date={{.Date}}
- -s -w -X github.com/observatorium/opentelemetry-collector-builder/cmd.version={{.Version}} -X github.com/observatorium/opentelemetry-collector-builder/cmd.date={{.Date}}
env:
- CGO_ENABLED=0
goos:
Expand All @@ -19,6 +19,9 @@ builds:
goarm:
- 6
- 7
hooks:
post:
- upx "{{ .Path }}"
archives:
- format: binary
replacements:
Expand Down
2 changes: 1 addition & 1 deletion internal/builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func Compile(cfg Config) error {
}

cfg.Logger.Info("Compiling")
cmd := exec.Command(goBinary, "build", "-trimpath", "-o", cfg.Distribution.ExeName)
cmd := exec.Command(goBinary, "build", "-ldflags=-s -w", "-trimpath", "-o", cfg.Distribution.ExeName)
cmd.Dir = cfg.Distribution.OutputPath
if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("failed to compile the OpenTelemetry Collector distribution: %w. Output: %q", err, out)
Expand Down

0 comments on commit c725aab

Please sign in to comment.