forked from aquasecurity/tracee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.tracee-container
197 lines (170 loc) · 3.95 KB
/
Makefile.tracee-container
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#
# Responsible for creating the official tracee container images
#
.PHONY: all
all: help
#
# make
#
.ONESHELL:
SHELL = /bin/sh
MAKEFLAGS += --no-print-directory
#
# tools
#
CMD_DOCKER ?= docker
CMD_RM ?= rm
.check_%:
#
@command -v $* >/dev/null
if [ $$? -ne 0 ]; then
echo "missing required tool $*"
exit 1
else
touch $@ # avoid target rebuilds due to inexistent file
fi
#
# usage
#
.PHONY: help
help:
@echo ""
@echo "To generate tracee containers:"
@echo ""
@echo " $$ make -f builder/Makefile.tracee-container build-tracee"
@echo " $$ make -f builder/Makefile.tracee-container build-tracee-full"
@echo ""
@echo "To execute tracee containers:"
@echo ""
@echo " $$ make -f builder/Makefile.tracee-container run-tracee"
@echo " $$ make -f builder/Makefile.tracee-container run-tracee-ebpf"
@echo ""
@echo " $$ make -f builder/Makefile.tracee-container run-tracee-full"
@echo " $$ make -f builder/Makefile.tracee-container run-tracee-ebpf-full"
@echo ""
@echo "Note: You may provide \"run\" arguments using the ARG variable."
@echo ""
@echo "Example:"
@echo ""
@echo " $$ make -f builder/Makefile.tracee-container build-tracee"
@echo ""
@echo " $$ make -f builder/Makefile.tracee-container run-tracee-ebpf-full \ "
@echo " ARG=\"--debug -trace comm=bash --trace follow'\" "
@echo ""
#
# requirements
#
.PHONY: .check_tree
.check_tree:
#
@if [ ! -d ./builder ]; then
echo "you must be in the root directory"
exit 1
fi
#
# create tracee & tracee-full
#
# BTFHUB is not set by default, but both of the official images, slim and full,
# should be built with BTFHUB=1. This will maximize chances of end user using
# the slim image AND also allow end user to pick the full image for all use
# cases (if that is what one wants).
ifeq ($(BTFHUB),)
BTFHUB=0
endif
TRACEE_CONT_NAME = tracee:latest
TRACEE_FULL_CONT_NAME = tracee:full
TRACEE_CONT_DOCKERFILE = builder/Dockerfile.alpine-tracee-container
.PHONY: build-tracee
build-tracee: \
| .check_$(CMD_DOCKER) \
.check_tree
#
$(CMD_DOCKER) build \
-f $(TRACEE_CONT_DOCKERFILE) \
-t $(TRACEE_CONT_NAME) \
--build-arg=BTFHUB=$(BTFHUB) \
--build-arg=FLAVOR=tracee-core \
--target tracee-core \
.
$(CMD_DOCKER) images \
--filter "label=AS=tracee-make" \
--format "{{.ID}}" \
| xargs $(CMD_DOCKER) rmi
.PHONY: build-tracee-full
build-tracee-full: \
| .check_$(CMD_DOCKER) \
.check_tree
#
$(CMD_DOCKER) build \
-f $(TRACEE_CONT_DOCKERFILE) \
-t $(TRACEE_FULL_CONT_NAME) \
--build-arg=BTFHUB=$(BTFHUB) \
--build-arg=FLAVOR=tracee-nocore \
--target tracee-nocore \
.
$(CMD_DOCKER) images \
--filter "label=AS=tracee-make" \
--format "{{.ID}}" \
| xargs $(CMD_DOCKER) rmi
#
# run tracee and tracee-full
#
DOCKER_RUN_ARGS = run --rm --pid=host --privileged \
-v /etc/os-release:/etc/os-release-host:ro \
-v /sys/kernel/security:/sys/kernel/security:ro \
-e LIBBPFGO_OSRELEASE_FILE=/etc/os-release-host \
-v /tmp/tracee:/tmp/tracee:rw
DOCKER_RUN_ARGS_FULL = $(DOCKER_RUN_ARGS) \
-v /lib/modules:/lib/modules:ro \
-v /usr/src:/usr/src:ro
.PHONY: run-tracee
run-tracee: \
| .check_$(CMD_DOCKER) \
.check_tree
#
$(CMD_DOCKER) \
$(DOCKER_RUN_ARGS) \
-e TRACEE_EBPF_ONLY=0 \
--rm -it $(TRACEE_CONT_NAME) \
$(ARG)
.PHONY: run-tracee-full
run-tracee-full: \
| .check_$(CMD_DOCKER) \
.check_tree
#
$(CMD_DOCKER) \
$(DOCKER_RUN_ARGS_FULL) \
-e TRACEE_EBPF_ONLY=0 \
-e FORCE_CORE=0 \
--rm -it $(TRACEE_FULL_CONT_NAME) \
$(ARG)
#
# run tracee-ebpf or tracee-ebpf-full
#
.PHONY: run-tracee-ebpf
run-tracee-ebpf: \
| .check_$(CMD_DOCKER) \
.check_tree
#
$(CMD_DOCKER) \
$(DOCKER_RUN_ARGS) \
-e TRACEE_EBPF_ONLY=1 \
--rm -it $(TRACEE_CONT_NAME) \
$(ARG)
.PHONY: run-tracee-ebpf-full
run-tracee-ebpf-full: \
| .check_$(CMD_DOCKER) \
.check_tree
#
$(CMD_DOCKER) \
$(DOCKER_RUN_ARGS_FULL) \
-e TRACEE_EBPF_ONLY=1 \
-e FORCE_CORE=0 \
--rm -it $(TRACEE_FULL_CONT_NAME) \
$(ARG)
#
# clean
#
.PHONY: clean
clean:
$(MAKE) clean