forked from stackrox/collector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
167 lines (133 loc) · 4.42 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
BASE_PATH = .
include Makefile-constants.mk
NPROCS ?= $(shell nproc)
MOD_VER_FILE=$(CURDIR)/kernel-modules/kobuild-tmp/MODULE_VERSION.txt
DEV_SSH_SERVER_KEY ?= $(CURDIR)/.collector_dev_ssh_host_ed25519_key
BUILD_BUILDER_IMAGE ?= false
export COLLECTOR_VERSION := $(COLLECTOR_TAG)
export MODULE_VERSION := $(shell cat $(CURDIR)/kernel-modules/MODULE_VERSION)
dev-build: image
make -C integration-tests TestProcessNetwork
.PHONY: tag
tag:
@echo "$(COLLECTOR_TAG)"
.PHONY: builder-tag
builder-tag:
@echo "$(COLLECTOR_BUILDER_TAG)"
.PHONY: container-dockerfile-dev
container-dockerfile-dev:
sed '1s/ubi-minimal/ubi/' $(CURDIR)/collector/container/Dockerfile > \
$(CURDIR)/collector/container/Dockerfile.dev
.PHONY: builder
builder:
ifneq ($(BUILD_BUILDER_IMAGE), false)
docker buildx build --load --platform ${PLATFORM} \
-t quay.io/stackrox-io/collector-builder:$(COLLECTOR_BUILDER_TAG) \
-f "$(CURDIR)/builder/Dockerfile" \
"$(CURDIR)/builder"
else
docker pull --platform ${PLATFORM} quay.io/stackrox-io/collector-builder:$(COLLECTOR_BUILDER_TAG)
endif
collector: check-builder
make -C collector collector
.PHONY: connscrape
connscrape:
make -C collector connscrape
.PHONY: unittest
unittest:
make -C collector unittest
.PHONY: build-kernel-modules
build-kernel-modules:
make -C kernel-modules build-container
.PHONY: build-drivers
build-drivers:
make -C kernel-modules drivers
image: collector unittest
make -C collector txt-files
docker buildx build --load --platform ${PLATFORM} \
--build-arg COLLECTOR_VERSION="$(COLLECTOR_TAG)" \
--build-arg MODULE_VERSION="$(MODULE_VERSION)" \
-f collector/container/Dockerfile \
-t quay.io/stackrox-io/collector:$(COLLECTOR_TAG) \
$(COLLECTOR_BUILD_CONTEXT)
image-dev: collector unittest container-dockerfile-dev
make -C collector txt-files
docker build --build-arg collector_version="$(COLLECTOR_TAG)" \
--build-arg BUILD_TYPE=devel \
--build-arg MODULE_VERSION="$(MODULE_VERSION)" \
-f collector/container/Dockerfile.dev \
-t quay.io/stackrox-io/collector:$(COLLECTOR_TAG) \
$(COLLECTOR_BUILD_CONTEXT)
image-dev-full: image-dev build-drivers
docker tag quay.io/stackrox-io/collector:$(COLLECTOR_TAG) quay.io/stackrox-io/collector:$(COLLECTOR_TAG)-slim
docker build \
--target=probe-layer-1 \
--tag quay.io/stackrox-io/collector:$(COLLECTOR_TAG)-full \
--build-arg collector_repo=quay.io/stackrox-io/collector \
--build-arg collector_version=$(COLLECTOR_TAG) \
--build-arg module_version=$(shell cat $(CURDIR)/kernel-modules/MODULE_VERSION) \
--build-arg max_layer_size=300 \
--build-arg max_layer_depth=1 \
$(CURDIR)/kernel-modules/container
.PHONY: integration-tests-report
integration-tests-report:
make -C integration-tests report
.PHONY: ci-integration-tests
ci-integration-tests:
make -C integration-tests ci-integration-tests
.PHONY: ci-benchmarks
ci-benchmarks:
make -C integration-tests ci-benchmarks
.PHONY: ci-all-tests
ci-all-tests: ci-benchmarks ci-integration-tests
$(DEV_SSH_SERVER_KEY):
ifeq (,$(wildcard $(DEV_SSH_SERVER_KEY)))
ssh-keygen -t ed25519 -N '' -f $(DEV_SSH_SERVER_KEY) < /dev/null
endif
.PHONY: start-builder
start-builder: builder teardown-builder
docker run -d \
--name $(COLLECTOR_BUILDER_NAME) \
-v $(CURDIR):$(CURDIR) \
$(if $(LOCAL_SSH_PORT),-p $(LOCAL_SSH_PORT):22 )\
-w $(CURDIR) \
--cap-add sys_ptrace \
quay.io/stackrox-io/collector-builder:$(COLLECTOR_BUILDER_TAG)
.PHONY: check-builder
check-builder:
$(CURDIR)/utilities/check-builder.sh $(COLLECTOR_BUILDER_NAME)
.PHONY: teardown-builder
teardown-builder:
docker rm -fv $(COLLECTOR_BUILDER_NAME)
.PHONY: clean
clean:
rm -rf cmake-build/
make -C collector clean
.PHONY: shfmt-check
shfmt-check:
shfmt -d $(CURDIR)
.PHONY: shfmt-format
shfmt-format:
shfmt -w $(CURDIR)
.PHONY: shellcheck-all
shellcheck-all:
./utilities/shellcheck-all/shellcheck-all.sh
.PHONY: shellcheck-all-dockerized
shellcheck-all-dockerized:
docker build -t shellcheck-all $(CURDIR)/utilities/shellcheck-all
docker run --rm -v "$(CURDIR):/scripts" shellcheck-all:latest
# This defines a macro that can be used to add pre-commit targets
# to check staged files (check-<linter name>) or all files (check-<linter name>-all)
define linter
check-$(1):
pre-commit run $(1)
check-$(1)-all:
pre-commit run --all-files $(1)
endef
$(eval $(call linter,flake8))
$(eval $(call linter,clang-format))
$(eval $(call linter,shellcheck))
$(eval $(call linter,shfmt))
.PHONY: linters
linters:
@$(CURDIR)/utilities/lint.sh