forked from amazon-archives/k8s-cloudwatch-adapter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (45 loc) · 1.74 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
REGISTRY?=chankh
IMAGE?=k8s-cloudwatch-adapter
TEMP_DIR:=$(shell mktemp -d /tmp/$(IMAGE).XXXXXX)
OUT_DIR?=./_output
VENDOR_DOCKERIZED=0
VERSION?=latest
GOIMAGE=golang:1.11
.PHONY: all docker-build push test build-local-image
all: test $(OUT_DIR)/adapter
src_deps=$(shell find pkg cmd -type f -name "*.go")
$(OUT_DIR)/adapter: $(src_deps)
CGO_ENABLED=0 GOARCH=$* go build -tags netgo -o $(OUT_DIR)/$*/adapter github.com/awslabs/k8s-cloudwatch-adapter/cmd/adapter
docker-build: verify-apis
cp deploy/Dockerfile $(TEMP_DIR)/Dockerfile
docker run -v $(TEMP_DIR):/build -v $(shell pwd):/go/src/github.com/awslabs/k8s-cloudwatch-adapter -e GOARCH=amd64 $(GOIMAGE) /bin/bash -c "\
CGO_ENABLED=0 go build -tags netgo -o /build/adapter github.com/awslabs/k8s-cloudwatch-adapter/cmd/adapter"
docker build -t $(REGISTRY)/$(IMAGE):$(VERSION) $(TEMP_DIR)
rm -rf $(TEMP_DIR)
build-local-image: $(OUT_DIR)/$(ARCH)/adapter
sed "s|BASEIMAGE|scratch|g" deploy/Dockerfile > $(TEMP_DIR)/Dockerfile
cp $(OUT_DIR)/$(ARCH)/adapter $(TEMP_DIR)
cd $(TEMP_DIR)
docker build -t $(REGISTRY)/$(IMAGE):$(VERSION) $(TEMP_DIR)
rm -rf $(TEMP_DIR)
push: docker-build
docker push $(REGISTRY)/$(IMAGE):$(VERSION)
vendor: Gopkg.lock
ifeq ($(VENDOR_DOCKERIZED),1)
docker run -it -v $(shell pwd):/go/src/github.com/awslabs/k8s-cloudwatch-adapter -w /go/src/github.com/awslabs/k8s-cloudwatch-adapter $(GOIMAGE) /bin/bash -c "\
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh \
&& dep ensure -vendor-only"
else
dep ensure -vendor-only -v
endif
test:
CGO_ENABLED=0 go test ./pkg/...
clean:
rm -rf ${OUT_DIR}
# Code gen helpers
gen-apis: codegen-get
hack/update-codegen.sh
verify-apis:
hack/verify-codegen.sh
codegen-get:
dep ensure -add k8s.io/code-generator/...