Add Makefile
[vaultmon/.git] / build.sh
CommitLineData
f9a7f48b
SB
1#!/bin/bash
2
3set -e
4
5EXTRA_ARGS="$@"
6
7IMAGE="gonitro/${PWD##*/}"
8TAG=$(git rev-parse --short HEAD)
9IMAGE_NAME="${IMAGE}:${TAG}"
10
fd025c6f
SB
11echo Building Go binary
12CGO_ENABLED=0 GOOS=linux go build -a -x -installsuffix cgo -ldflags '-d -s -w' .
13
14[[ `file vaultmon | awk '/executable/{print $2}'` != 'ELF' ]] && {
15 echo Must be a Linux ELF binary
16 exit 1
17}
18
f9a7f48b
SB
19echo Building Docker image ${IMAGE_NAME}
20docker build -t ${IMAGE_NAME} ${EXTRA_ARGS} .
21[[ $? -eq 0 ]] && {
22 docker tag ${IMAGE_NAME} ${IMAGE}:latest
23 echo Publishing ${IMAGE_NAME}
24 docker push ${IMAGE_NAME}
25 docker push ${IMAGE}:latest
26}
fd025c6f
SB
27
28exit 0