2016-09-05 21:58:49 +00:00
|
|
|
.PHONY: build
|
|
|
|
|
2016-09-20 18:03:42 +00:00
|
|
|
PATH := $(GOPATH)/bin:$(shell npm bin):$(PATH)
|
2017-01-30 19:37:27 +00:00
|
|
|
VERSION = $(shell git describe --tags --always --dirty)
|
2016-12-15 16:39:01 +00:00
|
|
|
BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
REVISION = $(shell git rev-parse HEAD)
|
|
|
|
REVSHORT = $(shell git rev-parse --short HEAD)
|
|
|
|
USER = $(shell whoami)
|
2017-10-04 21:28:11 +00:00
|
|
|
DOCKER_IMAGE_NAME = kolide/fleet
|
2016-10-12 16:25:59 +00:00
|
|
|
|
2016-09-20 18:03:42 +00:00
|
|
|
ifneq ($(OS), Windows_NT)
|
2016-12-15 16:39:01 +00:00
|
|
|
# If on macOS, set the shell to bash explicitly
|
2016-09-20 18:03:42 +00:00
|
|
|
ifeq ($(shell uname), Darwin)
|
|
|
|
SHELL := /bin/bash
|
|
|
|
endif
|
2016-08-10 05:15:44 +00:00
|
|
|
|
2016-12-15 16:39:01 +00:00
|
|
|
# The output binary name is different on Windows, so we're explicit here
|
2017-10-04 21:28:11 +00:00
|
|
|
OUTPUT = build/fleet
|
2016-08-10 05:15:44 +00:00
|
|
|
|
2016-12-15 16:39:01 +00:00
|
|
|
# To populate version metadata, we use unix tools to get certain data
|
|
|
|
GOVERSION = $(shell go version | awk '{print $$3}')
|
|
|
|
NOW = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
|
|
else
|
|
|
|
# The output binary name is different on Windows, so we're explicit here
|
2017-10-04 21:28:11 +00:00
|
|
|
OUTPUT = build/fleet.exe
|
2016-09-20 02:37:47 +00:00
|
|
|
|
2016-12-15 16:39:01 +00:00
|
|
|
# To populate version metadata, we use windows tools to get the certain data
|
2016-09-20 02:37:47 +00:00
|
|
|
GOVERSION_CMD = "(go version).Split()[2]"
|
|
|
|
GOVERSION = $(shell powershell $(GOVERSION_CMD))
|
|
|
|
NOW = $(shell powershell Get-Date -format s)
|
2016-09-04 05:13:42 +00:00
|
|
|
endif
|
|
|
|
|
2016-09-19 22:54:57 +00:00
|
|
|
ifndef CIRCLE_PR_NUMBER
|
2016-12-08 17:54:21 +00:00
|
|
|
DOCKER_IMAGE_TAG = ${REVSHORT}
|
2016-09-19 22:54:57 +00:00
|
|
|
else
|
2016-12-08 17:54:21 +00:00
|
|
|
DOCKER_IMAGE_TAG = dev-${CIRCLE_PR_NUMBER}-${REVSHORT}
|
2016-09-20 02:37:47 +00:00
|
|
|
endif
|
|
|
|
|
2017-02-02 16:30:23 +00:00
|
|
|
ifdef CIRCLE_TAG
|
|
|
|
DOCKER_IMAGE_TAG = ${CIRCLE_TAG}
|
|
|
|
endif
|
|
|
|
|
2017-02-06 19:34:56 +00:00
|
|
|
ifndef MYSQL_PORT_3306_TCP_ADDR
|
|
|
|
MYSQL_PORT_3306_TCP_ADDR = 127.0.0.1
|
|
|
|
endif
|
|
|
|
|
2017-10-12 16:42:13 +00:00
|
|
|
KIT_VERSION = "\
|
|
|
|
-X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.appName=${APP_NAME} \
|
|
|
|
-X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.version=${VERSION} \
|
|
|
|
-X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.branch=${BRANCH} \
|
|
|
|
-X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.revision=${REVISION} \
|
|
|
|
-X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.buildDate=${NOW} \
|
|
|
|
-X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.buildUser=${USER} \
|
|
|
|
-X github.com/kolide/fleet/vendor/github.com/kolide/kit/version.goVersion=${GOVERSION}"
|
|
|
|
|
2016-09-20 02:37:47 +00:00
|
|
|
all: build
|
|
|
|
|
|
|
|
define HELP_TEXT
|
|
|
|
|
|
|
|
Makefile commands
|
|
|
|
|
|
|
|
make deps - Install depedent programs and libraries
|
|
|
|
make generate - Generate and bundle required code
|
|
|
|
make generate-dev - Generate and bundle required code in a watch loop
|
|
|
|
make distclean - Delete all build artifacts
|
|
|
|
|
|
|
|
make build - Build the code
|
2017-01-30 16:34:29 +00:00
|
|
|
make package - Build rpm and deb packages for linux
|
2016-09-20 02:37:47 +00:00
|
|
|
|
|
|
|
make test - Run the full test suite
|
|
|
|
make test-go - Run the Go tests
|
|
|
|
make test-js - Run the JavaScript tests
|
2016-10-31 13:56:13 +00:00
|
|
|
|
|
|
|
make lint - Run all linters
|
2016-09-20 02:37:47 +00:00
|
|
|
make lint-go - Run the Go linters
|
|
|
|
make lint-js - Run the JavaScript linters
|
2016-10-31 13:56:13 +00:00
|
|
|
make lint-scss - Run the SCSS linters
|
2016-12-15 16:39:01 +00:00
|
|
|
make lint-ts - Run the TypeScript linters
|
2016-09-20 23:26:44 +00:00
|
|
|
|
2016-09-20 02:37:47 +00:00
|
|
|
endef
|
|
|
|
|
|
|
|
help:
|
|
|
|
$(info $(HELP_TEXT))
|
|
|
|
|
|
|
|
.prefix:
|
|
|
|
ifeq ($(OS), Windows_NT)
|
|
|
|
if not exist build mkdir build
|
2016-10-19 22:14:26 +00:00
|
|
|
else
|
2016-09-20 02:37:47 +00:00
|
|
|
mkdir -p build
|
2016-09-19 22:54:57 +00:00
|
|
|
endif
|
2016-09-14 17:19:11 +00:00
|
|
|
|
2016-12-15 16:39:01 +00:00
|
|
|
build: export GOGC = off
|
2017-02-02 16:30:23 +00:00
|
|
|
build: export CGO_ENABLED=0
|
2016-09-14 17:19:11 +00:00
|
|
|
build: .prefix
|
2017-10-12 16:42:13 +00:00
|
|
|
$(eval APP_NAME = fleet)
|
|
|
|
go build -i -o ${OUTPUT} -ldflags ${KIT_VERSION} ./cmd/fleet
|
2016-09-14 17:19:11 +00:00
|
|
|
|
2016-09-06 21:00:34 +00:00
|
|
|
lint-js:
|
2016-09-20 13:42:08 +00:00
|
|
|
eslint frontend --ext .js,.jsx
|
2016-12-15 16:39:01 +00:00
|
|
|
|
2016-10-31 21:02:06 +00:00
|
|
|
lint-ts:
|
|
|
|
tslint frontend/**/*.tsx frontend/**/*.ts
|
2016-12-15 16:39:01 +00:00
|
|
|
|
2016-10-28 21:25:57 +00:00
|
|
|
lint-scss:
|
|
|
|
sass-lint --verbose
|
2016-09-06 21:00:34 +00:00
|
|
|
|
|
|
|
lint-go:
|
2016-09-04 05:13:42 +00:00
|
|
|
go vet $(shell glide nv)
|
2016-09-06 21:00:34 +00:00
|
|
|
|
2017-10-12 17:06:29 +00:00
|
|
|
lint: lint-go lint-js lint-scss lint-ts
|
2016-09-06 21:00:34 +00:00
|
|
|
|
|
|
|
test-go:
|
2017-01-04 21:59:17 +00:00
|
|
|
go test $(shell glide nv)
|
|
|
|
|
|
|
|
analyze-go:
|
|
|
|
go test -race -cover $(shell glide nv)
|
|
|
|
|
2016-09-06 21:00:34 +00:00
|
|
|
|
2016-12-15 16:39:01 +00:00
|
|
|
test-js: export NODE_PATH = ./frontend
|
2016-09-06 21:00:34 +00:00
|
|
|
test-js:
|
2016-12-15 16:39:01 +00:00
|
|
|
_mocha --compilers js:babel-core/register,tsx:typescript-require \
|
|
|
|
--recursive "frontend/**/*.tests.js*" \
|
2016-09-28 10:16:09 +00:00
|
|
|
--require ignore-styles \
|
2016-12-15 16:39:01 +00:00
|
|
|
--require "frontend/.test.setup.js" \
|
|
|
|
--require "frontend/test/loaderMock.js"
|
2016-09-06 21:00:34 +00:00
|
|
|
|
2016-10-31 13:56:13 +00:00
|
|
|
test: lint test-go test-js
|
2016-09-04 05:13:42 +00:00
|
|
|
|
2016-08-10 05:15:44 +00:00
|
|
|
generate: .prefix
|
2017-01-19 15:24:10 +00:00
|
|
|
NODE_ENV=production webpack --progress --colors
|
2016-09-26 18:48:55 +00:00
|
|
|
go-bindata -pkg=service \
|
|
|
|
-o=server/service/bindata.go \
|
2016-09-20 02:37:47 +00:00
|
|
|
frontend/templates/ assets/...
|
2016-12-20 21:54:30 +00:00
|
|
|
go-bindata -pkg=kolide -o=server/kolide/bindata.go server/mail/templates
|
2016-09-06 15:08:11 +00:00
|
|
|
|
2016-11-16 13:47:49 +00:00
|
|
|
|
2016-09-22 00:40:26 +00:00
|
|
|
# we first generate the webpack bundle so that bindata knows to watch the
|
|
|
|
# output bundle file. then, generate debug bindata source file. finally, we
|
|
|
|
# run webpack in watch mode to continuously re-generate the bundle
|
2016-09-06 15:08:11 +00:00
|
|
|
generate-dev: .prefix
|
2016-09-20 18:54:07 +00:00
|
|
|
webpack --progress --colors
|
2016-09-26 18:48:55 +00:00
|
|
|
go-bindata -debug -pkg=service \
|
|
|
|
-o=server/service/bindata.go \
|
2016-09-20 02:37:47 +00:00
|
|
|
frontend/templates/ assets/...
|
2016-12-20 21:54:30 +00:00
|
|
|
go-bindata -pkg=kolide -o=server/kolide/bindata.go server/mail/templates
|
2017-03-13 19:13:33 +00:00
|
|
|
webpack --progress --colors --watch
|
2016-08-10 05:15:44 +00:00
|
|
|
|
|
|
|
deps:
|
2017-02-10 18:22:26 +00:00
|
|
|
yarn
|
2017-04-06 19:12:20 +00:00
|
|
|
go get -u \
|
|
|
|
github.com/jteeuwen/go-bindata/... \
|
|
|
|
github.com/Masterminds/glide \
|
|
|
|
github.com/groob/mockimpl
|
2017-02-10 20:51:33 +00:00
|
|
|
glide install --strip-vendor
|
2016-08-10 05:15:44 +00:00
|
|
|
|
2016-08-10 15:31:27 +00:00
|
|
|
distclean:
|
2016-09-20 02:37:47 +00:00
|
|
|
ifeq ($(OS), Windows_NT)
|
|
|
|
if exist build rmdir /s/q build
|
|
|
|
if exist vendor rmdir /s/q vendor
|
|
|
|
if exist assets\bundle.js del assets\bundle.js
|
|
|
|
else
|
|
|
|
rm -rf build vendor
|
|
|
|
rm -f assets/bundle.js
|
|
|
|
endif
|
2016-08-10 05:15:44 +00:00
|
|
|
|
2017-02-13 22:57:16 +00:00
|
|
|
docker-build-release:
|
|
|
|
docker build -t "${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" .
|
2017-10-04 21:28:11 +00:00
|
|
|
docker tag "${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" kolide/fleet:latest
|
2017-02-13 22:57:16 +00:00
|
|
|
docker push "${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}"
|
2017-10-04 21:28:11 +00:00
|
|
|
docker push kolide/fleet:latest
|
2016-09-20 23:26:44 +00:00
|
|
|
|
2016-09-19 22:54:57 +00:00
|
|
|
docker-build-circle:
|
|
|
|
@echo ">> building docker image"
|
|
|
|
docker build -t "${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}" .
|
2016-09-22 00:43:48 +00:00
|
|
|
docker push "${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}"
|
2017-01-23 17:32:19 +00:00
|
|
|
|
|
|
|
demo-dump:
|
|
|
|
mysqldump --extended-insert=FALSE --skip-dump-date \
|
|
|
|
-u kolide -p \
|
|
|
|
-h ${MYSQL_PORT_3306_TCP_ADDR} kolide \
|
|
|
|
> ./tools/app/demo.sql
|
|
|
|
|
|
|
|
demo-restore:
|
|
|
|
mysql --binary-mode -u kolide -p \
|
|
|
|
-h ${MYSQL_PORT_3306_TCP_ADDR} kolide \
|
|
|
|
< ./tools/app/demo.sql
|