Make sure we're building a Linux binary
authorSofian Brabez <sbz@6dev.net>
Thu, 24 May 2018 10:43:55 +0000 (11:43 +0100)
committerSofian Brabez <sbz@6dev.net>
Thu, 24 May 2018 10:43:55 +0000 (11:43 +0100)
build.sh

index f87638ac9e447e0151ef2f0cf863ad268a067344..bd64c68a02862a25d7bae8e240acb5977ee32000 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -8,6 +8,14 @@ IMAGE="gonitro/${PWD##*/}"
 TAG=$(git rev-parse --short HEAD)
 IMAGE_NAME="${IMAGE}:${TAG}"
 
+echo Building Go binary
+CGO_ENABLED=0 GOOS=linux go build -a -x -installsuffix cgo -ldflags '-d -s -w' .
+
+[[ `file vaultmon | awk '/executable/{print $2}'` != 'ELF' ]] && {
+    echo Must be a Linux ELF binary
+    exit 1
+}
+
 echo Building Docker image ${IMAGE_NAME}
 docker build -t ${IMAGE_NAME} ${EXTRA_ARGS} .
 [[ $? -eq 0 ]] && {
@@ -16,3 +24,5 @@ docker build -t ${IMAGE_NAME} ${EXTRA_ARGS} .
     docker push ${IMAGE_NAME}
     docker push ${IMAGE}:latest
 }
+
+exit 0