Add a script for building a statically linked executable.

This is the script we use at Kumina to build binaries that can be
deployed across our cluster easily.
This commit is contained in:
Ed Schouten 2017-10-19 16:23:50 +02:00
parent 11f53c8612
commit 91ad2ff620
1 changed files with 17 additions and 0 deletions

17
build_static.sh Executable file
View File

@ -0,0 +1,17 @@
#!/bin/sh
docker run -i -v `pwd`:/unbound_exporter alpine:edge /bin/sh << 'EOF'
set -ex
# Install prerequisites for the build process.
apk update
apk add ca-certificates git go libc-dev
update-ca-certificates
# Build the unbound_exporter.
cd /unbound_exporter
export GOPATH=/gopath
go get -d ./...
go build --ldflags '-extldflags "-static"'
strip unbound_exporter
EOF