Skip to content
Snippets Groups Projects
Commit 6e112718 authored by Rohith's avatar Rohith
Browse files

Merge pull request #10 from gambol99/build

Build
parents bae1f773 a776ef8c
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,10 @@ ...@@ -2,7 +2,10 @@
NAME=keycloak-proxy NAME=keycloak-proxy
AUTHOR=gambol99 AUTHOR=gambol99
HARDWARE=$(shell uname -m) HARDWARE=$(shell uname -m)
VERSION=$(shell awk '/version =/ { print $$3 }' doc.go | sed 's/"//g') GOVERSION=1.5.3
GIT_COMMIT=$(shell git log --pretty=format:'%h' -n 1)
ROOT_DIR=${PWD}
VERSION=$(shell awk '/version.*=/ { print $$3 }' doc.go | sed 's/"//g')
DEPS=$(shell go list -f '{{range .TestImports}}{{.}} {{end}}' ./...) DEPS=$(shell go list -f '{{range .TestImports}}{{.}} {{end}}' ./...)
PACKAGES=$(shell go list ./...) PACKAGES=$(shell go list ./...)
VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr
...@@ -11,16 +14,31 @@ VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf ...@@ -11,16 +14,31 @@ VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf
default: build default: build
build: golang:
@echo "--> Go Version"
@go version
buildtags: golang
@echo "--> Adding the build tags"
@echo "package main" > build.go
@echo "" >> build.go
@echo "const buildID = \"$(VERSION), git+sha: ${GIT_COMMIT}\"" >> build.go
build: buildtags
@echo "--> Compiling the project" @echo "--> Compiling the project"
mkdir -p bin mkdir -p bin
godep go build -o bin/${NAME} godep go build -o bin/${NAME}
static: static: buildtags deps
@echo "--> Compiling the static binary" @echo "--> Compiling the static binary"
mkdir -p bin mkdir -p bin
CGO_ENABLED=0 GOOS=linux godep go build -a -tags netgo -ldflags '-w' -o bin/${NAME} CGO_ENABLED=0 GOOS=linux godep go build -a -tags netgo -ldflags '-w' -o bin/${NAME}
docker-build:
@echo "--> Compiling the project"
sudo docker run --rm -v ${ROOT_DIR}:/go/src/github.com/gambol99/keycloak-proxy \
-w /go/src/github.com/gambol99/keycloak-proxy -e GOOS=linux golang:${GOVERSION} make static
docker: static docker: static
@echo "--> Building the docker image" @echo "--> Building the docker image"
sudo docker build -t docker.io/${AUTHOR}/${NAME}:${VERSION} . sudo docker build -t docker.io/${AUTHOR}/${NAME}:${VERSION} .
...@@ -40,6 +58,7 @@ authors: ...@@ -40,6 +58,7 @@ authors:
deps: deps:
@echo "--> Installing build dependencies" @echo "--> Installing build dependencies"
@go get github.com/tools/godep
@go get -d -v ./... $(DEPS) @go get -d -v ./... $(DEPS)
vet: vet:
......
package main
const buildID = "v0.0.5, git+sha: da94978"
...@@ -32,7 +32,7 @@ func main() { ...@@ -32,7 +32,7 @@ func main() {
kc := cli.NewApp() kc := cli.NewApp()
kc.Name = prog kc.Name = prog
kc.Usage = description kc.Usage = description
kc.Version = version kc.Version = buildID
kc.Author = author kc.Author = author
kc.Email = email kc.Email = email
kc.Flags = getOptions() kc.Flags = getOptions()
...@@ -75,6 +75,6 @@ func main() { ...@@ -75,6 +75,6 @@ func main() {
// printUsage display the command line usage and error // printUsage display the command line usage and error
func printUsage(message string) { func printUsage(message string) {
fmt.Fprintf(os.Stderr, "[error] %s", message) fmt.Fprintf(os.Stderr, "[error] %s\n", message)
os.Exit(1) os.Exit(1)
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment