forked from linkerd/linkerd2-proxy-init
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (63 loc) · 2.4 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
DOCKER_REGISTRY ?= ghcr.io/linkerd
CLUSTER_NAME ?= kind
REPO = $(DOCKER_REGISTRY)/proxy-init
TESTER_REPO = $(DOCKER_REGISTRY)/iptables-tester
VERSION ?= $(shell git describe --exact-match --tags 2> /dev/null || git rev-parse --short HEAD)
SUPPORTED_ARCHS = linux/amd64,linux/arm64,linux/arm/v7
PUSH_IMAGE ?= false
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show this help
@echo 'Info: For integration test using KinD, run make kind-load integration-test'
@echo 'Info: For other environments, run make integration-test after having uploaded the images'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
###############
# Go
###############
.PHONY: build
build: ## Build the project
go build -o out/linkerd2-proxy-init main.go
.PHONY: run
run: ## Run the project
go run main.go
.PHONY: test
test: ## Perform unit test
go test -v ./...
.PHONY: fmt
fmt: ## Check the code formatting
gofmt -d .
test -z "$(shell gofmt -d .)"
.PHONY: integration-test
integration-test: image ## Perform integration test
cd integration_test && ./run_tests.sh
###############
# Docker
###############
.PHONY: image
image: ## Build docker image for the project
DOCKER_BUILDKIT=1 docker build -t $(REPO):latest .
.PHONY: tester-image
tester-image: ## Build docker image for the tester component
docker build -t $(TESTER_REPO):v1 -f ./integration_test/iptables/Dockerfile-tester ./integration_test
.PHONY: kind-load
kind-load: image tester-image ## Load the required image to KinD cluster
kind load docker-image $(REPO):latest --name $(CLUSTER_NAME)
kind load docker-image $(TESTER_REPO):v1 --name $(CLUSTER_NAME)
.PHONY: images
images: ## Build multi arch docker images for the project
docker buildx build \
--platform $(SUPPORTED_ARCHS) \
--output "type=image,push=$(PUSH_IMAGE)" \
--tag $(REPO):$(VERSION) \
.
.PHONY: push
push: ## Push multi arch docker images to the registry
PUSH_IMAGE=true make images
.PHONY: inspect-manifest
inspect-manifest: ## Check the resulting images supported architecture
docker run --rm mplatform/mquery $(REPO):$(VERSION)
.PHONY: builder
builder: ## Create the Buildx builder instance
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
docker buildx create --name=multiarch-builder --driver=docker-container --platform="$(SUPPORTED_ARCHS)" --use
docker buildx inspect multiarch-builder --bootstrap