Skip to content

Commit f4ca2a3

Browse files
author
Ed Schouten
committed
Add a nifty script for building statically linked binaries.
We use this script at Kumina to generate binaries that we can deploy to a wide variety of Linux systems. Let's keep this in the tree, like we do for some of our other exporters.
1 parent a571ffd commit f4ca2a3

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

build_static.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
docker run -i -v `pwd`:/dovecot_exporter alpine:edge /bin/sh << 'EOF'
4+
set -ex
5+
6+
# Install prerequisites for the build process.
7+
apk update
8+
apk add ca-certificates git go libc-dev
9+
update-ca-certificates
10+
11+
# Build the dovecot_exporter.
12+
cd /dovecot_exporter
13+
export GOPATH=/gopath
14+
go get -d ./...
15+
go build --ldflags '-extldflags "-static"'
16+
strip dovecot_exporter
17+
EOF

0 commit comments

Comments
 (0)