draft-classic/Makefile

147 строки
3.4 KiB
Makefile
Исходник Обычный вид История

2017-05-08 19:33:37 +03:00
DOCKER_REGISTRY ?= docker.io
IMAGE_PREFIX ?= microsoft
IMAGE_TAG ?= canary
2017-05-09 02:12:05 +03:00
SHORT_NAME ?= draft
TARGETS = darwin/amd64 linux/amd64 linux/386 linux/arm windows/amd64
2017-01-18 11:10:11 +03:00
DIST_DIRS = find * -type d -exec
2017-04-21 18:19:58 +03:00
APP = draft
2017-01-18 11:10:11 +03:00
# go option
GO ?= go
PKG := $(shell glide novendor)
2017-03-13 22:18:29 +03:00
TAGS := kqueue
2017-01-18 11:10:11 +03:00
TESTS := .
TESTFLAGS :=
LDFLAGS :=
GOFLAGS :=
BINDIR := $(CURDIR)/bin
2017-04-21 18:19:58 +03:00
BINARIES := draft
2017-01-18 11:10:11 +03:00
# Required for globs to work correctly
SHELL=/bin/bash
.PHONY: all
all: build
.PHONY: build
build:
2017-05-08 19:33:37 +03:00
GOBIN=$(BINDIR) $(GO) install $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/Azure/draft/cmd/...
2017-01-18 11:10:11 +03:00
2017-04-21 18:19:58 +03:00
# usage: make clean build-cross dist APP=draft|draftd VERSION=v2.0.0-alpha.3
2017-01-18 11:10:11 +03:00
.PHONY: build-cross
build-cross: LDFLAGS += -extldflags "-static"
build-cross:
2017-05-08 19:33:37 +03:00
CGO_ENABLED=0 gox -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/Azure/draft/cmd/$(APP)
2017-01-18 11:10:11 +03:00
.PHONY: dist
dist:
( \
cd _dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
2017-04-21 18:19:58 +03:00
$(DIST_DIRS) tar -zcf draft-${VERSION}-{}.tar.gz {} \; \
2017-01-18 11:10:11 +03:00
)
.PHONY: checksum
checksum:
2017-04-11 22:00:18 +03:00
for f in _dist/*.gz ; do \
2017-01-18 11:10:11 +03:00
shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256" ; \
done
2017-01-20 22:06:37 +03:00
.PHONY: check-docker
check-docker:
@if [ -z $$(which docker) ]; then \
echo "Missing \`docker\` client which is required for development"; \
exit 2; \
fi
.PHONY: check-helm
check-helm:
@if [ -z $$(which helm) ]; then \
echo "Missing \`helm\` client which is required for development"; \
exit 2; \
fi
2017-01-20 22:06:37 +03:00
.PHONY: docker-binary
docker-binary: BINDIR = ./rootfs/bin
docker-binary: GOFLAGS += -a -installsuffix cgo
docker-binary:
2017-05-08 19:33:37 +03:00
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 $(GO) build -o $(BINDIR)/draftd $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/Azure/draft/cmd/draftd
2017-01-20 22:06:37 +03:00
.PHONY: docker-build
docker-build: check-docker docker-binary compress-binary
2017-01-20 23:19:13 +03:00
docker build --rm -t ${IMAGE} .
2017-01-20 22:06:37 +03:00
docker tag ${IMAGE} ${MUTABLE_IMAGE}
.PHONY: compress-binary
compress-binary: BINDIR = ./rootfs/bin
compress-binary:
@if [ -z $$(which upx) ]; then \
echo "Missing \`upx\` tool to compress binaries"; \
else \
2017-04-21 18:19:58 +03:00
upx --quiet ${BINDIR}/draftd; \
fi
.PHONY: serve
serve: check-helm
helm install chart/ --name ${APP} --namespace kube-system \
--set image.repository=${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${SHORT_NAME},image.tag=${IMAGE_TAG}
.PHONY: unserve
unserve: check-helm
-helm delete --purge ${APP}
.PHONY: clean
clean:
-rm bin/*
-rm rootfs/bin/*
-rm -rf _dist/
2017-01-18 11:10:11 +03:00
.PHONY: test
test: TESTFLAGS += -race -v
test: test-lint test-unit
2017-06-06 21:39:04 +03:00
test-cover:
scripts/cover.sh
.PHONY: test-lint
test-lint:
scripts/lint.sh
2017-01-18 11:10:11 +03:00
.PHONY: test-unit
test-unit:
$(GO) test $(GOFLAGS) -cover -run $(TESTS) $(PKG) $(TESTFLAGS)
2017-01-18 11:10:11 +03:00
2017-02-10 01:27:59 +03:00
.PHONY: test-e2e
test-e2e:
./tests/e2e.sh
HAS_GOMETALINTER := $(shell command -v gometalinter;)
2017-01-18 11:10:11 +03:00
HAS_GLIDE := $(shell command -v glide;)
HAS_GOX := $(shell command -v gox;)
HAS_GIT := $(shell command -v git;)
HAS_BINDATA := $(shell command -v go-bindata;)
2017-01-18 11:10:11 +03:00
.PHONY: bootstrap
bootstrap:
ifndef HAS_GOMETALINTER
go get -u github.com/alecthomas/gometalinter
gometalinter --install
endif
2017-01-18 11:10:11 +03:00
ifndef HAS_GLIDE
go get -u github.com/Masterminds/glide
endif
ifndef HAS_GOX
go get -u github.com/mitchellh/gox
endif
ifndef HAS_GIT
$(error You must install git)
endif
ifndef HAS_BINDATA
go get github.com/jteeuwen/go-bindata/...
2017-01-18 11:10:11 +03:00
endif
glide install --strip-vendor
scripts/setup-apimachinery.sh
2017-01-18 11:10:11 +03:00
include versioning.mk