Created
April 21, 2016 18:47
-
-
Save zankich/aaaadeeb08bf2530eef530e612e6fcb2 to your computer and use it in GitHub Desktop.
script for building consul and consul-template with docker
This file contains hidden or 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/bash -exu | |
## | |
## This script generates consul and consul-template binaries. | |
## You may run this from inside a docker container with: | |
## | |
## docker pull golang:1.6.1 | |
## docker run -v $PWD:/opt/build -t golang:1.6.1 /opt/build/build.sh | |
## | |
function build_consul() { | |
pushd /tmp > /dev/null | |
wget -O consul-0.5.2.tar.gz https://github.com/hashicorp/consul/archive/v0.5.2.tar.gz | |
tar xvf consul-0.5.2.tar.gz -C $GOPATH/src/github.com/hashicorp/ | |
popd > /dev/null | |
pushd $GOPATH/src/github.com/hashicorp > /dev/null | |
mv consul-0.5.2 consul | |
popd > /dev/null | |
pushd $GOPATH/src/github.com/hashicorp/consul > /dev/null | |
mkdir -p Godeps | |
cp deps/v0-5-2.json Godeps/Godeps.json | |
godep restore | |
go build -ldflags "-X main.GitCommit \"9a9cc9341bb487651a0399e3fc5e1e8a42e62dd9\" -X main.GitDescribe \"0.5.2-golang161\"" \ | |
-v \ | |
-o $BIN_TARGET/consul | |
popd > /dev/null | |
pushd $BIN_TARGET > /dev/null | |
tar -cvzf consul_0.5.2-golang161_linux_amd64.tar.gz consul | |
rm consul | |
popd | |
} | |
function build_vault() { | |
pushd /tmp > /dev/null | |
wget -O vault-0.1.0.tar.gz https://github.com/hashicorp/vault/archive/v0.1.0.tar.gz | |
tar xvf vault-0.1.0.tar.gz -C $GOPATH/src/github.com/hashicorp/ | |
popd > /dev/null | |
pushd $GOPATH/src/github.com/hashicorp > /dev/null | |
mv vault-0.1.0 vault | |
popd > /dev/null | |
} | |
function build_consul-template() { | |
pushd /tmp > /dev/null | |
wget -O consul-template-0.9.0.tar.gz https://github.com/hashicorp/consul-template/archive/v0.9.0.tar.gz | |
tar xvf consul-template-0.9.0.tar.gz -C $GOPATH/src/github.com/hashicorp/ | |
popd > /dev/null | |
pushd $GOPATH/src/github.com/hashicorp > /dev/null | |
mv consul-template-0.9.0 consul-template | |
popd > /dev/null | |
pushd $GOPATH/src/github.com/hashicorp/consul-template > /dev/null | |
sed -i.bak 's/0.9.0/0.9.0-golang161/g' main.go | |
go build -v -o $BIN_TARGET/consul-template | |
popd > /dev/null | |
pushd $BIN_TARGET > /dev/null | |
tar -cvzf consul-template_0.9.0-golang161_linux_amd64.tar.gz consul-template | |
rm consul-template | |
popd | |
} | |
function setup_env() { | |
export GOPATH=/tmp/gopath | |
export BIN_TARGET=/opt/build | |
export PATH=$GOPATH/bin:$PATH | |
mkdir -p $GOPATH/src/github.com/hashicorp/ | |
apt-get update && apt-get install git wget | |
go get github.com/tools/godep | |
} | |
function main() { | |
setup_env | |
build_consul | |
build_vault | |
build_consul-template | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment