Makefile: Use docker image to build ebpf object files.
@@ -14,8 +14,6 @@ ENABLE_BTFGEN ?= false
BPFTOOL ?= bpftool
ARCH ?= $(shell uname -m | sed 's/x86_64/x86/' | sed 's/aarch64/arm64/' | sed 's/ppc64le/powerpc/' | sed 's/mips.*/mips/')
-DOCKERFILES_DIR=Dockerfiles
-
# Adds a '-dirty' suffix to version string if there are uncommitted changes
changes := $(shell git status --porcelain)
ifeq ($(changes),)
@@ -55,7 +53,11 @@ all: build local-gadget
phony_explicit:
ebpf-objects:
- TARGET=$(GOHOSTARCH) go generate ./...
+ docker run --rm --name ebpf-object-builder --user $(shell id -u):$(shell id -g) -v $(shell pwd):/work ghcr.io/kinvolk/inspektor-gadget-ebpf-builder
+
+epbf-objects-outside-docker:
+ TARGET=arm64 go generate ./...
+ TARGET=amd64 go generate ./...
# local-gadget
@@ -76,7 +78,7 @@ local-gadget: local-gadget-$(GOHOSTOS)-$(GOHOSTARCH)
local-gadget-%: phony_explicit
echo Building local-gadget-$* && \
export GOOS=$(shell echo $* |cut -f1 -d-) GOARCH=$(shell echo $* |cut -f2 -d-) && \
- docker build -t local-gadget-$*-builder -f $(DOCKERFILES_DIR)/local-gadget.Dockerfile \
+ docker build -t local-gadget-$*-builder -f Dockerfiles/local-gadget.Dockerfile \
--build-arg GOOS=$${GOOS} --build-arg GOARCH=$${GOARCH} --build-arg VERSION=$(VERSION) . && \
docker run --rm --entrypoint cat local-gadget-$*-builder local-gadget-$* > local-gadget-$* && \
chmod +x local-gadget-$*
@@ -113,13 +115,13 @@ install/kubectl-gadget: kubectl-gadget-$(GOHOSTOS)-$(GOHOSTARCH)
# gadget BCC container image
.PHONY: gadget-default-container
gadget-default-container:
- docker buildx build -t $(CONTAINER_REPO):$(IMAGE_TAG) -f $(DOCKERFILES_DIR)/gadget-default.Dockerfile \
+ docker buildx build -t $(CONTAINER_REPO):$(IMAGE_TAG) -f Dockerfiles/gadget-default.Dockerfile \
--build-arg ENABLE_BTFGEN=$(ENABLE_BTFGEN) .
# gadget CO-RE container image
.PHONY: gadget-core-container
gadget-core-container:
- docker buildx build -t $(CONTAINER_REPO):$(IMAGE_TAG) -f $(DOCKERFILES_DIR)/gadget-core.Dockerfile \
+ docker buildx build -t $(CONTAINER_REPO):$(IMAGE_TAG) -f Dockerfiles/gadget-core.Dockerfile \
--build-arg ENABLE_BTFGEN=$(ENABLE_BTFGEN) .
.PHONY: push-gadget-container
@@ -129,7 +131,7 @@ push-gadget-container:
# kubectl-gadget container image
.PHONY: kubectl-gadget-container
kubectl-gadget-container:
- docker build -t kubectl-gadget -f $(DOCKERFILES_DIR)/kubectl-gadget.Dockerfile \
+ docker build -t kubectl-gadget -f Dockerfiles/kubectl-gadget.Dockerfile \
--build-arg IMAGE_TAG=$(IMAGE_TAG) .
# tests
