Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: build static task #6

Open
flaccid opened this issue Jul 10, 2017 · 2 comments
Open

feature: build static task #6

flaccid opened this issue Jul 10, 2017 · 2 comments

Comments

@flaccid
Copy link

flaccid commented Jul 10, 2017

Could we implement a task for the Makefile to do something like CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo .?

This helps to build a static binary for a docker image that has no dynamics.

@flaccid
Copy link
Author

flaccid commented Jul 10, 2017

Not sure if this is good enough, but seems to do the job for me...

# Build Static
.PHONY: static
static: fmt lint vendor | $(BASE) ; $(info $(M) building static executable…) @ ## Build static program binary
	$Q cd $(BASE) && CGO_ENABLED=0 $(GO) build \
		-a \
		-installsuffix cgo \
		-tags release \
		-ldflags '-X $(PACKAGE)/cmd.Version=$(VERSION) -X $(PACKAGE)/cmd.BuildDate=$(DATE)' \
		-o bin/$(PACKAGE) main.go

@vincentbernat
Copy link
Owner

I think this is good enough. I don't add it directly because adding features goes against the "minimal" Makefile I try to provide here. But people interested in such a rule are likely to find this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants