-
Notifications
You must be signed in to change notification settings - Fork 179
/
Makefile
116 lines (88 loc) · 3.84 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
.PHONY: all build builder clean clean-package compress dev generate mocks package release release-cli release-image release-provider release-version version-gen test test-docker
commands = atom build monitor rack router
injects = convox-env
# commands = build rack router
# injects =
assets = $(wildcard assets/*)
binaries = $(addprefix $(GOPATH)/bin/, $(commands))
sources = $(shell find . -name '*.go')
statics = $(addprefix $(GOPATH)/bin/, $(injects))
DEV ?= true
ifeq ($(DEV), false)
VERSION := $(shell date +%Y%m%d%H%M%S)
else ifndef VERSION
VERSION := $(shell date +%Y%m%d%H%M%S)-dev
endif
all: build
build: $(binaries) $(statics)
builder:
docker build -t convox/build:$(USER) -f cmd/build/Dockerfile .
docker push convox/build:$(USER)
clean: clean-package
make -C cmd/convox clean
clean-package:
find . -name '*-packr.go' -delete
compress: $(binaries) $(statics)
upx-ucl -1 $^
dev:
test -n "$(RACK)" # RACK
docker build --target development -t convox/rack:dev .
ifdef UPLOAD
docker push convox/rack:dev
kubectl patch deployment/api -p '{"spec":{"template":{"spec":{"containers":[{"name":"main","imagePullPolicy":"Always"}]}}}}' -n $(RACK)
kubectl patch deployment/router -p '{"spec":{"template":{"spec":{"containers":[{"name":"main","imagePullPolicy":"Always"}]}}}}' -n convox-system
endif
convox rack update dev --wait
kubectl delete pod --all -n convox-system
kubectl delete pod --all -n $(RACK)
kubectl rollout status deployment/api -n $(RACK)
kubectl rollout status deployment/router -n convox-system
convox rack logs
generate:
go run cmd/generate/main.go controllers > pkg/api/controllers.go
go run cmd/generate/main.go routes > pkg/api/routes.go
go run cmd/generate/main.go sdk > sdk/methods.go
make -C pkg/atom generate
make -C provider/k8s generate
make -C provider/kaws generate
generate-provider:
go run cmd/generate/main.go controllers > pkg/api/controllers.go
go run cmd/generate/main.go routes > pkg/api/routes.go
go run cmd/generate/main.go sdk > sdk/methods.go
mocks: generate-provider
go get -u github.com/vektra/mockery/.../
make -C pkg/structs mocks
mockery -case underscore -dir pkg/start -outpkg sdk -output pkg/mock/start -name Interface
mockery -case underscore -dir sdk -outpkg sdk -output pkg/mock/sdk -name Interface
mockery -case underscore -dir vendor/github.com/aws/aws-sdk-go/service/cloudwatch/cloudwatchiface -outpkg aws -output pkg/mock/aws -name CloudWatchAPI
mockery -case underscore -dir vendor/github.com/convox/stdcli -outpkg stdcli -output pkg/mock/stdcli -name Executor
package:
go run -mod=vendor vendor/github.com/gobuffalo/packr/packr/main.go
regions:
@aws-vault exec convox-release-standard go run provider/aws/cmd/regions/main.go
@aws-vault exec convox-release-govcloud go run provider/aws/cmd/regions/main.go
release:
test -n "$(VERSION)" # VERSION
git tag $(VERSION) -m $(VERSION)
git push origin refs/tags/$(VERSION)
release-all: release-version release-cli release-image release-provider
release-cli: release-version package
make -C cmd/convox release VERSION=$(VERSION)
release-image: release-version package
docker buildx build --platform linux/amd64 -t convox/rack:$(VERSION) --no-cache --pull --push .
docker buildx build --platform linux/arm64 -t convox/rack:$(VERSION)-arm64 --no-cache --pull --push -f Dockerfile.arm .
release-provider: release-version package
make -C provider release VERSION=$(VERSION)
release-version:
test -n "$(VERSION)" # VERSION
version-gen:
@echo $(shell date +%Y%m%d%H%M%S)
test:
env PROVIDER=test go test -covermode atomic -coverprofile coverage.txt ./...
test-docker:
docker build -t convox/rack:test --target development .
docker run -it convox/rack:test make test
$(binaries): $(GOPATH)/bin/%: $(sources)
go install --ldflags="-s -w" ./cmd/$*
$(statics): $(GOPATH)/bin/%: $(sources)
env CGO_ENABLED=0 go install --ldflags '-extldflags "-static" -s -w' ./cmd/$*