forked from solo-io/bumblebee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
121 lines (96 loc) · 4.06 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
117
118
119
120
121
#----------------------------------------------------------------------------------
# Versioning
#----------------------------------------------------------------------------------
OUTDIR?=_output
HUB?=ghcr.io/solo-io
REPO_NAME?=bumblebee
EXAMPLES_DIR?=examples
DOCKER := docker
RELEASE := "true"
ifeq ($(TAGGED_VERSION),)
TAGGED_VERSION := $(shell git describe --tags --dirty --always)
RELEASE := "false"
endif
# In iron mountain escrow action we pass in the tag as TAGGED_VERSION: ${{ github.ref }}.
# This tag has the refs/tags prefix, which we need to remove here.
export VERSION ?= $(shell echo $(TAGGED_VERSION) | sed -e "s/^refs\/tags\///" | cut -c 2-)
LDFLAGS := "-X github.com/solo-io/bumblebee/pkg/internal/version.Version=$(VERSION)"
GCFLAGS := all="-N -l"
SOURCES := $(shell find . -name "*.go" | grep -v test.go)
.PHONY: clean
clean:
rm -f $(EXAMPLES_DIR)/**/*.o
rm -rf $(OUTDIR)
#----------------------------------------------------------------------------------
# Build Container
#----------------------------------------------------------------------------------
PUSH_CMD:=
PLATFORMS?=linux/amd64
docker-build:
# may run into issues with apt-get and the apt.llvm.org repo, in which case use --no-cache to build
# e.g. `docker build --no-cache ./builder -f builder/Dockerfile -t $(HUB)/bumblebee/builder:$(VERSION)
$(DOCKER) build --platform $(PLATFORMS) $(PUSH_CMD) ./builder -f builder/Dockerfile -t $(HUB)/bumblebee/builder:$(VERSION)
docker-push: PUSH_CMD=--push
docker-push: DOCKER=docker buildx
docker-push: PLATFORMS=linux/amd64,linux/arm64/v8
docker-push: docker-build
#----------------------------------------------------------------------------------
# Examples
#----------------------------------------------------------------------------------
.PHONY: activeconn
activeconn: $(EXAMPLES_DIR)/activeconn
.PHONY: tcpconnect
tcpconnect: $(EXAMPLES_DIR)/tcpconnect
.PHONY: exitsnoop
exitsnoop: $(EXAMPLES_DIR)/exitsnoop
.PHONY: oomkill
oomkill: $(EXAMPLES_DIR)/oomkill
.PHONY: capable
capable: $(EXAMPLES_DIR)/capable
.PHONY: tcpconnlat
tcpconnlat: $(EXAMPLES_DIR)/tcpconnlat
$(EXAMPLES_DIR)/%:
$(OUTDIR)/bee-linux-amd64 build $@/$*.c $(HUB)/$(REPO_NAME)/$*:$(VERSION)
$(OUTDIR)/bee-linux-amd64 push $(HUB)/$(REPO_NAME)/$*:$(VERSION)
.PHONY: release-examples
release-examples: activeconn tcpconnect exitsnoop oomkill capable tcpconnlat
#----------------------------------------------------------------------------------
# CLI
#----------------------------------------------------------------------------------
$(OUTDIR)/bee-linux-amd64: $(SOURCES)
CGO_ENABLED=0 GOARCH=amd64 GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ bee/main.go
.PHONY: bee-linux-amd64
bee-linux-amd64: $(OUTDIR)/bee-linux-amd64.sha256
$(OUTDIR)/bee-linux-amd64.sha256: $(OUTDIR)/bee-linux-amd64
sha256sum $(OUTDIR)/bee-linux-amd64 > $@
$(OUTDIR)/bee-linux-arm64: $(SOURCES)
CGO_ENABLED=0 GOARCH=arm64 GOOS=linux go build -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) -o $@ bee/main.go
.PHONY: bee-linux-arm64
bee-linux-arm64: $(OUTDIR)/bee-linux-arm64.sha256
$(OUTDIR)/bee-linux-arm64.sha256: $(OUTDIR)/bee-linux-arm64
sha256sum $(OUTDIR)/bee-linux-arm64 > $@
.PHONY: build-cli
build-cli: bee-linux-amd64 bee-linux-arm64
.PHONY: install-cli
install-cli:
CGO_ENABLED=0 go install -ldflags=$(LDFLAGS) -gcflags=$(GCFLAGS) ./bee
BEE_DIR := bee
$(OUTDIR)/Dockerfile-bee: $(BEE_DIR)/Dockerfile-bee
cp $< $@
.PHONY: docker-build-bee
docker-build-bee: build-cli $(OUTDIR)/Dockerfile-bee
$(DOCKER) build $(OUTDIR) -f $(OUTDIR)/Dockerfile-bee -t $(HUB)/bumblebee/bee:$(VERSION)
.PHONY: docker-push-bee
docker-push-bee: docker-build-bee
$(DOCKER) push $(HUB)/bumblebee/bee:$(VERSION)
##----------------------------------------------------------------------------------
## Release
##----------------------------------------------------------------------------------
.PHONY: upload-github-release-assets
upload-github-release-assets: build-cli
ifeq ($(RELEASE),"true")
go run ci/release_assets.go
endif
.PHONY: regen-vmlinux
regen-vmlinux:
bpftool btf dump file /sys/kernel/btf/vmlinux format c > builder/vmlinux.h