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:
Derek Parker 2021-12-30 00:04:59 -08:00 committed by GitHub
parent 38410993c9
commit a88c9bde4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 2 deletions

@ -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")
} }

@ -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

@ -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

@ -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", "./..." ]