Last active
August 28, 2016 16:36
-
-
Save thockin/36674d78bf213608f0e2ae4de06ef30d to your computer and use it in GitHub Desktop.
Use docker to build Go, via Makefile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bin/$(ARCH)/$(BIN): FORCE | |
@mkdir -p bin/$(ARCH) | |
@mkdir -p .go/src/$(GO_PKG) .go/pkg .go/bin .go/std/$(ARCH) | |
docker run \ | |
-u $$(id -u):$$(id -g) \ | |
-v $$(pwd)/.go:/go \ | |
-v $$(pwd):/go/src/$(GO_PKG) \ | |
-v $$(pwd)/bin/$(ARCH):/go/bin \ | |
-v $$(pwd)/.go/std/$(ARCH):/usr/local/go/pkg/linux_$(ARCH)_static \ | |
$(BUILD_IMAGE) \ | |
/bin/sh -c " \ | |
cd /go/src/$(GO_PKG) && \ | |
CGO_ENABLED=0 \ | |
go install \ | |
-installsuffix static \ | |
./... \ | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In this case
BUILD_IMAGE=golang:1.7.0-alpine
,ARCH=amd64
,BIN=yourapp
, andGO_PKG=github.com/yourname/yourapp