-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
75 lines (53 loc) · 2.49 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
ALL_ARCH = amd64 arm64
.EXPORT_ALL_VARIABLES:
all: $(addprefix build-arch-,$(ALL_ARCH))
VERSION_MAJOR ?= 1
VERSION_MINOR ?= 27
VERSION_BUILD ?= 1
TAG?=v$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_BUILD)
FLAGS=
ENVVAR=CGO_ENABLED=0
LDFLAGS?=-s
GOOS?=$(shell go env GOOS)
GOARCH?=$(shell go env GOARCH)
REGISTRY?=fred78290
BUILD_DATE?=`date +%Y-%m-%dT%H:%M:%SZ`
VERSION_LDFLAGS=-X main.phVersion=$(TAG)
IMAGE=$(REGISTRY)/aws-autoscaler
deps:
go mod vendor
# wget "https://raw.githubusercontent.com/Fred78290/autoscaler/master/cluster-autoscaler/cloudprovider/grpc/grpc.proto" -O grpc/grpc.proto
# protoc -I . -I vendor grpc/grpc.proto --go_out=plugins=grpc:.
build: $(addprefix build-arch-,$(ALL_ARCH))
build-arch-%: deps clean-arch-%
$(ENVVAR) GOOS=$(GOOS) GOARCH=$* go build -buildvcs=false -ldflags="-X main.phVersion=$(TAG) -X main.phBuildDate=$(BUILD_DATE) ${LDFLAGS}" -a -o out/$(GOOS)/$*/aws-autoscaler
test-unit: clean build
bash ./scripts/run-tests.sh
make-image: $(addprefix make-image-arch-,$(ALL_ARCH))
make-image-arch-%:
docker build --pull -t ${IMAGE}-$*:${TAG} -f Dockerfile.$* .
@echo "Image ${TAG}-$* completed"
push-image: $(addprefix push-image-arch-,$(ALL_ARCH))
push-image-arch-%:
docker push ${IMAGE}-$*:${TAG}
push-manifest:
docker buildx build --pull --platform linux/amd64,linux/arm64 --push -t ${IMAGE}:${TAG} .
@echo "Image ${TAG}* completed"
container-push-manifest: container push-manifest
clean: $(addprefix clean-arch-,$(ALL_ARCH))
clean-arch-%:
rm -f ./out/$(GOOS)/$*/aws-autoscaler
docker-builder:
docker build -t kubernetes-aws-autoscaler-builder ./builder
build-in-docker: $(addprefix build-in-docker-arch-,$(ALL_ARCH))
build-in-docker-arch-%: clean-arch-% docker-builder
docker run --rm -v `pwd`:/gopath/src/github.com/Fred78290/aws-autoscaler/ kubernetes-aws-autoscaler-builder:latest bash \
-c 'cd /gopath/src/github.com/Fred78290/aws-autoscaler \
&& BUILD_TAGS=${BUILD_TAGS} make -e REGISTRY=${REGISTRY} -e TAG=${TAG} -e BUILD_DATE=`date +%Y-%m-%dT%H:%M:%SZ` build-arch-$*'
container: $(addprefix container-arch-,$(ALL_ARCH))
container-arch-%: build-in-docker-arch-%
@echo "Full in-docker image ${TAG}-$* completed"
test-in-docker: docker-builder
docker run --rm -v `pwd`:/gopath/src/github.com/Fred78290/kubernetes-aws-autoscaler/ kubernetes-aws-autoscaler-builder:latest bash \
-c 'cd /gopath/src/github.com/Fred78290/kubernetes-aws-autoscaler && bash ./scripts/run-tests.sh'
.PHONY: all build test-unit clean docker-builder build-in-docker push-image push-manifest