Making the build completely static for docker 71/37271/1
authorKiran Kamineni <kiran.k.kamineni@intel.com>
Fri, 9 Mar 2018 19:49:24 +0000 (11:49 -0800)
committerKiran Kamineni <kiran.k.kamineni@intel.com>
Tue, 20 Mar 2018 22:17:43 +0000 (15:17 -0700)
Making the build static is good for deployment on a container.
There is no need to worry about installing dependencies and so on.

Issue-ID: AAF-182
Change-Id: I6bb34ccae423886d9154b2a713b81911f739e9ff
Signed-off-by: Kiran Kamineni <kiran.k.kamineni@intel.com>
sms-service/src/sms/Makefile

index 2751fff..25c12e1 100644 (file)
@@ -1,5 +1,6 @@
 GOPATH := $(shell realpath "$(PWD)/../../")
 BINARY := sms
+PLATFORM := linux
 DEPENDENCIES := github.com/golang/dep/cmd/dep
 
 export GOPATH ...
@@ -8,7 +9,9 @@ all: test build
 deploy: test build
 
 build: deps format
-       go build -o $(GOPATH)/target/$(BINARY) -v sms.go
+       CGO_ENABLED=0 GOOS=$(PLATFORM) go build -a \
+       -ldflags '-extldflags "-static"' \
+       -o $(GOPATH)/target/$(BINARY) -v sms.go
 
 clean:
        go clean