pkg/proc: add build scripts & docker image for ebpf (#2847)
Adds a few build scripts and a container image for reproducible builds of the ebpf programs.
This commit is contained in:
parent
38410993c9
commit
a88c9bde4a
9
Makefile
9
Makefile
@ -1,5 +1,6 @@
|
|||||||
.DEFAULT_GOAL=test
|
.DEFAULT_GOAL=test
|
||||||
|
|
||||||
|
SHELL := /bin/bash
|
||||||
GO_SRC := $(shell find . -type f -not -path './_fixtures/*' -not -path './vendor/*' -not -path './_scripts/*' -not -path './localtests/*' -name '*.go')
|
GO_SRC := $(shell find . -type f -not -path './_fixtures/*' -not -path './vendor/*' -not -path './_scripts/*' -not -path './localtests/*' -name '*.go')
|
||||||
|
|
||||||
check-cert:
|
check-cert:
|
||||||
@ -29,4 +30,10 @@ test-integration-run:
|
|||||||
vendor:
|
vendor:
|
||||||
@go run _scripts/make.go vendor
|
@go run _scripts/make.go vendor
|
||||||
|
|
||||||
.PHONY: vendor test-integration-run test-proc-run test check-cert install build vet uninstall
|
build-ebpf-image:
|
||||||
|
./pkg/proc/internal/ebpf/build/build-ebpf-builder-img.sh
|
||||||
|
|
||||||
|
build-ebpf-object: build-ebpf-image
|
||||||
|
./pkg/proc/internal/ebpf/build/build-ebpf-objects.sh
|
||||||
|
|
||||||
|
.PHONY: vendor test-integration-run test-proc-run test check-cert install build vet uninstall build-ebpf-image build-ebpf-object
|
||||||
|
|||||||
@ -208,7 +208,6 @@ func getDlvBin(t *testing.T) (string, string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getDlvBinEBPF(t *testing.T) (string, string) {
|
func getDlvBinEBPF(t *testing.T) (string, string) {
|
||||||
os.Setenv("CGO_LDFLAGS", "/usr/lib/libbpf.a")
|
|
||||||
return getDlvBinInternal(t, "-tags", "ebpf")
|
return getDlvBinInternal(t, "-tags", "ebpf")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
5
pkg/proc/internal/ebpf/build/build-ebpf-builder-img.sh
Executable file
5
pkg/proc/internal/ebpf/build/build-ebpf-builder-img.sh
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
sudo docker build \
|
||||||
|
-t delve-ebpf-builder:v0.0.1 \
|
||||||
|
-f pkg/proc/internal/ebpf/build/ebpf-Dockerfile ./pkg/proc/internal/ebpf/build
|
||||||
17
pkg/proc/internal/ebpf/build/build-ebpf-objects.sh
Executable file
17
pkg/proc/internal/ebpf/build/build-ebpf-objects.sh
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash -e
|
||||||
|
|
||||||
|
# The go generate command seems to not like being run from
|
||||||
|
# the vendor directory. Remove it and restore it after.
|
||||||
|
rm -rf vendor
|
||||||
|
|
||||||
|
restore_vendor() {
|
||||||
|
git checkout vendor
|
||||||
|
}
|
||||||
|
|
||||||
|
trap restore_vendor EXIT
|
||||||
|
|
||||||
|
docker run \
|
||||||
|
-it \
|
||||||
|
--rm \
|
||||||
|
-v "$(pwd)":/delve-bpf \
|
||||||
|
delve-ebpf-builder:v0.0.1
|
||||||
19
pkg/proc/internal/ebpf/build/ebpf-Dockerfile
Normal file
19
pkg/proc/internal/ebpf/build/ebpf-Dockerfile
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
FROM ubuntu:21.04
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
build-essential \
|
||||||
|
gcc-multilib \
|
||||||
|
git \
|
||||||
|
wget \
|
||||||
|
clang \
|
||||||
|
linux-headers-5.11.0-40 \
|
||||||
|
libbpf-dev
|
||||||
|
|
||||||
|
RUN wget https://golang.org/dl/go1.17.3.linux-amd64.tar.gz
|
||||||
|
RUN tar -C /usr/local -xzf go1.17.3.linux-amd64.tar.gz
|
||||||
|
RUN cp /usr/local/go/bin/go /usr/bin/go
|
||||||
|
|
||||||
|
WORKDIR /delve-bpf/pkg/proc/internal/ebpf/
|
||||||
|
|
||||||
|
CMD [ "go", "generate", "./..." ]
|
||||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user