2015-09-18 05:14:15 -04:00
|
|
|
|
|
|
|
NAME=vault-sidekick
|
2016-04-27 19:40:08 -04:00
|
|
|
AUTHOR ?= ukhomeofficedigital
|
|
|
|
REGISTRY ?= quay.io
|
2016-10-01 18:14:08 -04:00
|
|
|
GOVERSION ?= 1.7.1
|
2015-09-18 05:14:15 -04:00
|
|
|
HARDWARE=$(shell uname -m)
|
2015-09-23 17:39:50 -04:00
|
|
|
VERSION=$(shell awk '/Version =/ { print $$3 }' main.go | sed 's/"//g')
|
2015-10-12 07:35:12 -04:00
|
|
|
VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr
|
2015-09-18 05:14:15 -04:00
|
|
|
|
2015-09-21 11:35:59 -04:00
|
|
|
.PHONY: test authors changelog build docker static release
|
2015-09-18 05:14:15 -04:00
|
|
|
|
|
|
|
default: build
|
|
|
|
|
2016-10-01 18:14:08 -04:00
|
|
|
build: deps
|
2015-10-12 07:35:12 -04:00
|
|
|
@echo "--> Compiling the project"
|
2015-09-21 11:35:59 -04:00
|
|
|
mkdir -p bin
|
2016-10-01 18:14:08 -04:00
|
|
|
godep go build -o bin/${NAME}
|
2015-09-18 05:14:15 -04:00
|
|
|
|
2016-10-01 18:14:08 -04:00
|
|
|
static: deps
|
2015-10-12 07:35:12 -04:00
|
|
|
@echo "--> Compiling the static binary"
|
2015-09-21 11:35:59 -04:00
|
|
|
mkdir -p bin
|
2016-10-01 18:14:08 -04:00
|
|
|
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 ${PWD}:/go/src/github.com/UKHomeOffice/${NAME} \
|
|
|
|
-w /go/src/github.com/UKHomeOffice/${NAME} \
|
|
|
|
-e GOOS=linux \
|
|
|
|
golang:${GOVERSION} \
|
|
|
|
make static
|
2015-09-21 11:35:59 -04:00
|
|
|
|
2016-03-16 09:12:57 -04:00
|
|
|
docker: static
|
|
|
|
@echo "--> Building the docker image"
|
2016-04-27 19:40:08 -04:00
|
|
|
docker build -t ${REGISTRY}/${AUTHOR}/${NAME}:${VERSION} .
|
2016-03-16 09:12:57 -04:00
|
|
|
|
2016-10-01 18:46:18 -04:00
|
|
|
docker-release:
|
|
|
|
@echo "--> Building a release image"
|
|
|
|
@make static
|
|
|
|
@make docker
|
|
|
|
@docker push ${REGISTRY}/${AUTHOR}/${NAME}:${VERSION}
|
|
|
|
|
2015-09-23 09:21:54 -04:00
|
|
|
push: docker
|
2015-10-12 07:35:12 -04:00
|
|
|
@echo "--> Pushing the image to docker.io"
|
2016-10-01 18:14:08 -04:00
|
|
|
docker push ${REGISTRY}/${AUTHOR}/${NAME}:${VERSION}
|
2015-09-23 09:21:54 -04:00
|
|
|
|
2015-09-21 11:35:59 -04:00
|
|
|
release: static
|
|
|
|
mkdir -p release
|
|
|
|
gzip -c bin/${NAME} > release/${NAME}_${VERSION}_linux_${HARDWARE}.gz
|
|
|
|
rm -f release/${NAME}
|
2015-09-18 13:06:53 -04:00
|
|
|
|
2015-09-18 09:12:09 -04:00
|
|
|
clean:
|
2015-09-21 11:35:59 -04:00
|
|
|
rm -rf ./bin 2>/dev/null
|
2015-09-23 17:58:23 -04:00
|
|
|
rm -rf ./release 2>/dev/null
|
2015-09-18 13:06:53 -04:00
|
|
|
|
2015-09-18 05:14:15 -04:00
|
|
|
authors:
|
2015-10-12 07:35:12 -04:00
|
|
|
@echo "--> Updating the AUTHORS"
|
2015-09-18 05:14:15 -04:00
|
|
|
git log --format='%aN <%aE>' | sort -u > AUTHORS
|
|
|
|
|
2015-10-12 07:35:12 -04:00
|
|
|
deps:
|
|
|
|
@echo "--> Installing build dependencies"
|
2016-10-01 18:14:08 -04:00
|
|
|
@go get github.com/tools/godep
|
2015-10-12 07:35:12 -04:00
|
|
|
|
|
|
|
vet:
|
|
|
|
@echo "--> Running go tool vet $(VETARGS) ."
|
|
|
|
@go tool vet 2>/dev/null ; if [ $$? -eq 3 ]; then \
|
|
|
|
go get golang.org/x/tools/cmd/vet; \
|
|
|
|
fi
|
|
|
|
@go tool vet $(VETARGS) .
|
|
|
|
|
|
|
|
format:
|
|
|
|
@echo "--> Running go fmt"
|
|
|
|
@go fmt $(PACKAGES)
|
|
|
|
|
2016-10-01 18:18:21 -04:00
|
|
|
gofmt:
|
|
|
|
@echo "--> Running gofmt check"
|
|
|
|
@gofmt -s -l *.go \
|
|
|
|
| grep -q \.go ; if [ $$? -eq 0 ]; then \
|
|
|
|
echo "You need to runn the make format, we have file unformatted"; \
|
|
|
|
gofmt -s -l *.go; \
|
|
|
|
exit 1; \
|
|
|
|
fi
|
2015-10-12 06:23:36 -04:00
|
|
|
cover:
|
2015-10-12 07:35:12 -04:00
|
|
|
@echo "--> Running go cover"
|
2016-10-01 18:18:21 -04:00
|
|
|
@godep go test --cover
|
2015-10-12 06:23:36 -04:00
|
|
|
|
2015-10-12 07:35:12 -04:00
|
|
|
test: deps
|
|
|
|
@echo "--> Running the tests"
|
2015-09-18 05:14:15 -04:00
|
|
|
go test -v
|
2016-10-01 18:18:21 -04:00
|
|
|
@$(MAKE) gofmt
|
2015-10-12 07:35:12 -04:00
|
|
|
@$(MAKE) vet
|
2015-09-18 05:14:15 -04:00
|
|
|
|
|
|
|
changelog: release
|
2015-09-18 13:06:53 -04:00
|
|
|
git log $(shell git tag | tail -n1)..HEAD --no-merges --format=%B > changelog
|