github.com/Bio-core/jtree@v0.0.0-20190705165106-1d7a7e7d6272/Makefile (about) 1 .PHONY: build build-alpine clean test database help default 2 3 BIN_NAME=jtree 4 5 VERSION := $(shell grep "const Version " version.go | sed -E 's/.*"(.+)"$$/\1/') 6 GIT_COMMIT=$(shell git rev-parse HEAD) 7 GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true) 8 IMAGE_NAME := "jtree/jtree" 9 10 default: test 11 12 help: 13 @echo 'Management commands for jtree:' 14 @echo 15 @echo 'Usage:' 16 @echo ' make build Compile the project.' 17 @echo ' make get-deps runs glide install, mostly used for ci.' 18 @echo ' make build-alpine Compile optimized for alpine linux.' 19 @echo ' make package Build final docker image with just the go binary inside' 20 @echo ' make tag Tag image created by package with latest, git commit and version' 21 @echo ' make test Run tests on a compiled project.' 22 @echo ' make push Push tagged images to registry' 23 @echo ' make clean Clean the directory tree.' 24 @echo ' make database creates the database structure.' 25 @echo 26 27 build: 28 @echo "building ${BIN_NAME} ${VERSION}" 29 @echo "GOPATH=${GOPATH}" 30 go build -ldflags "-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X main.VersionPrerelease=DEV" -o bin/${BIN_NAME} cmd/jtree-metadata-server/main.go 31 32 get-deps: 33 glide install 34 35 build-alpine: 36 @echo "building ${BIN_NAME} ${VERSION}" 37 @echo "GOPATH=${GOPATH}" 38 go build -ldflags '-w -linkmode external -extldflags "-static" -X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X main.VersionPrerelease=VersionPrerelease=RC' -o bin/${BIN_NAME} cmd/jtree-metadata-server/main.go 39 40 package: 41 @echo "building image ${BIN_NAME} ${VERSION} $(GIT_COMMIT)" 42 docker build --build-arg VERSION=${VERSION} --build-arg GIT_COMMIT=$(GIT_COMMIT) -t $(IMAGE_NAME):local . 43 44 tag: 45 @echo "Tagging: latest ${VERSION} $(GIT_COMMIT)" 46 docker tag $(IMAGE_NAME):local $(IMAGE_NAME):$(GIT_COMMIT) 47 docker tag $(IMAGE_NAME):local $(IMAGE_NAME):${VERSION} 48 docker tag $(IMAGE_NAME):local $(IMAGE_NAME):latest 49 50 push: tag 51 @echo "Pushing docker image to registry: latest ${VERSION} $(GIT_COMMIT)" 52 docker push $(IMAGE_NAME):$(GIT_COMMIT) 53 docker push $(IMAGE_NAME):${VERSION} 54 docker push $(IMAGE_NAME):latest 55 56 clean: 57 @test ! -e bin/${BIN_NAME} || rm bin/${BIN_NAME} 58 59 test: 60 go test -coverprofile c.out ./tests -test.v GOCACHE=off 61 bash travisCheck.sh 62 63 database: 64 bash ./sql/DatabaseRebuild.sh 65