Skip to content

Instantly share code, notes, and snippets.

@miked0004
Last active May 15, 2018 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miked0004/d459405f954b7887146a5072a6979cdc to your computer and use it in GitHub Desktop.
Save miked0004/d459405f954b7887146a5072a6979cdc to your computer and use it in GitHub Desktop.
demo using docker to compile terraform master branch
#!/usr/bin/env bash
#
# this will cross-compile terraform from source and drop the zipped
# packages in ./build
#
# this is only an exercise for docker, it is not a recommended usage
# of anything
#
mkdir -p ./build
cat<<-EOF | docker build --rm -t my/gobuilder -
FROM golang
RUN set -x \
&& apt-get update \
&& apt-get install -y zip unzip \
&& apt-get clean
RUN set -x \
&& go get github.com/hashicorp/terraform
EOF
docker run --rm -it -v "$(pwd)":/host my/gobuilder /bin/bash -cx '
cd /go/src/github.com/hashicorp/terraform &&
git pull &&
XC_OS="linux darwin" XC_ARCH="amd64" make bin &&
cp /go/src/github.com/hashicorp/terraform/pkg/*.zip /host/build'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment