-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
91 lines (62 loc) · 2.54 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
## PHONY
.PHONY: help setup clean clobber dev image docker deploy build build-all www-build www-dev test test-env test-go test-all deps-update deps-go services
## VARIABLES
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
VERSION := $(shell git rev-parse HEAD)
os = $(shell echo $(1) | cut -d"_" -f1)
arch = $(shell echo $(1) | cut -d"_" -f2)
## COMMANDS
help: ## show help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
build: build/$(GOOS)_$(GOARCH)/cmd ## build for current system
build-all: build/linux_amd64/cmd build/darwin_amd64/cmd ## build for all systems
build/%/cmd:
GOOS=$(call os, $*) GOARCH=$(call arch, $*) \
go build -ldflags "-X main.Version=$(VERSION)" -o $@ ./cmd/cmd
dev: services deps-update ## run dev harness
comlab dev
services: ## run backing services
docker-compose -f dev/services.yml up -d
setup: deps-update ## setup development environment
go get -u github.com/gliderlabs/comlab/...
clean: ## delete typical build artifacts
-rm -rf build
clobber: clean ## reset dev environment
docker-compose -f dev/services.yml down
-rm -rf vendor
-rm -f .git/deps-*
image: ui-build build/linux_amd64/cmd ## build docker image
docker build -t gliderlabs/cmd .
deploy-alpha: build/linux_amd64/cmd ## deploy to alpha channel
sigil -p -f run/channels/alpha.yaml image=$(IMAGE) | kubectl apply --namespace cmd -f -
kubectl rollout status deployment/cmd-alpha --namespace cmd --watch
deploy-beta: build/linux_amd64/cmd ## deploy to beta channel
sigil -p -f run/channels/beta.yaml image=$(IMAGE) | kubectl apply --namespace cmd -f -
kubectl rollout status deployment/cmd-beta --namespace cmd --watch
## TESTS
test: test-go ## run common tests
test-all: test-go test-env ## run ALL tests
test-go: ## run golang tests
go test -v $(shell glide nv)
test-env: services ## test dev environment
docker build -t cmd-env -f dev/setup/Dockerfile .
docker run --rm \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
--volume $(shell pwd)/.env:/usr/local/src/github.com/gliderlabs/cmd/.env:ro \
--env DYNAMODB_ENDPOINT=http://$(shell docker inspect dev_dynamodb_1 --format '{{ .NetworkSettings.Networks.dev_default.IPAddress }}'):8000 \
cmd-env
-docker rmi cmd-env
## WRAPPERS
ui-build:
$(MAKE) -C ui build
www-build:
$(MAKE) -C www build
www-dev:
$(MAKE) -C www dev
## DEPENDENCIES
deps-update: ## update dependencies if changed
./dev/deps.sh
deps-go:
glide install -v
git log -n 1 --pretty=format:%h -- glide.yaml > .git/deps-go