From 74710ae71ab3ac85d7e466b22d3f4db4b6315a3c Mon Sep 17 00:00:00 2001 From: Ryan Schlesinger Date: Tue, 28 Mar 2017 05:40:05 -0700 Subject: [PATCH] Add docker cross compilation instructions (#12931) --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index a7b9eea32..f4b36b564 100644 --- a/README.md +++ b/README.md @@ -152,3 +152,13 @@ $ tree ./pkg/ -P "terraform|*.zip" ``` _Note: Cross-compilation uses [gox](https://github.com/mitchellh/gox), which requires toolchains to be built with versions of Go prior to 1.5. In order to successfully cross-compile with older versions of Go, you will need to run `gox -build-toolchain` before running the commands detailed above._ + +#### Docker + +When using docker you don't need to have any of the Go development tools installed and you can clone terraform to any location on disk (doesn't have to be in your $GOPATH). This is useful for users who want to build `master` or a specific branch for testing without setting up a proper Go environment. + +For example, run the following command to build terraform in a linux-based container for macOS. + +```sh +docker run --rm -v $(pwd):/go/src/github.com/hashicorp/terraform -w /go/src/github.com/hashicorp/terraform -e XC_OS=darwin -e XC_ARCH=amd64 golang:latest bash -c "apt-get update && apt-get install -y zip && make bin" +```