diff --git a/Dockerfile.bpftracebase b/Dockerfile.bpftracebase deleted file mode 100644 index a6b1ff77..00000000 --- a/Dockerfile.bpftracebase +++ /dev/null @@ -1,46 +0,0 @@ -FROM alpine:3.8 as builder -ARG bpftracesha -ARG bccversion -ENV STATIC_LINKING=ON -ENV RUN_TESTS=0 -RUN apk add --update \ - bison \ - build-base \ - clang-dev \ - clang-static \ - curl \ - cmake \ - elfutils-dev \ - flex-dev \ - git \ - linux-headers \ - llvm5-dev \ - llvm5-static \ - python \ - zlib-dev - -# Put LLVM directories where CMake expects them to be -RUN ln -s /usr/lib/cmake/llvm5 /usr/lib/cmake/llvm -RUN ln -s /usr/include/llvm5/llvm /usr/include/llvm -RUN ln -s /usr/include/llvm5/llvm-c /usr/include/llvm-c - -WORKDIR / -RUN curl -L https://github.com/iovisor/bcc/archive/v${bccversion}.tar.gz \ - --output /bcc.tar.gz -RUN tar xvf /bcc.tar.gz -RUN mv bcc-${bccversion} bcc -RUN cd /bcc && mkdir build && cd build && cmake .. && make install -j4 && \ - cp src/cc/libbcc.a /usr/local/lib64/libbcc.a && \ - cp src/cc/libbcc-loader-static.a /usr/local/lib64/libbcc-loader-static.a && \ - cp src/cc/libbpf.a /usr/local/lib64/libbpf.a - -ADD https://github.com/iovisor/bpftrace/archive/${bpftracesha}.tar.gz /bpftrace.tar.gz -RUN tar -xvf /bpftrace.tar.gz - -RUN mv bpftrace-${bpftracesha} /bpftrace - -WORKDIR /bpftrace - -WORKDIR /bpftrace/docker - -RUN sh build.sh /bpftrace/build-release Release bpftrace diff --git a/Dockerfile.tracerunner b/Dockerfile.tracerunner deleted file mode 100644 index 70a4609d..00000000 --- a/Dockerfile.tracerunner +++ /dev/null @@ -1,22 +0,0 @@ -ARG bpftracesha -ARG imagenamebase - -FROM ${imagenamebase}:${bpftracesha} as bpftrace -FROM golang:1.11.4-alpine3.8 as gobuilder - -RUN apk update -RUN apk add make bash git - -ADD . /go/src/github.com/iovisor/kubectl-trace -WORKDIR /go/src/github.com/iovisor/kubectl-trace - -RUN make _output/bin/trace-runner - -FROM alpine:3.8 - -RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 -COPY --from=bpftrace /bpftrace/build-release/src/bpftrace /bin/bpftrace -COPY --from=gobuilder /go/src/github.com/iovisor/kubectl-trace/_output/bin/trace-runner /bin/trace-runner - -ENTRYPOINT ["/bin/trace-runner"] - diff --git a/Makefile b/Makefile index 3c7496fc..6c31a5d9 100644 --- a/Makefile +++ b/Makefile @@ -8,25 +8,20 @@ GIT_COMMIT := $(if $(shell git status --porcelain --untracked-files=no),${COMMIT GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD 2>/dev/null) GIT_BRANCH_CLEAN := $(shell echo $(GIT_BRANCH) | sed -e "s/[^[:alnum:]]/-/g") -IMAGE_NAME ?= quay.io/iovisor/kubectl-trace-bpftrace -IMAGE_NAME_BASE ?= quay.io/iovisor/kubectl-trace-bpftrace-base - IMAGE_NAME_INIT ?= quay.io/iovisor/kubectl-trace-init +IMAGE_NAME ?= quay.io/iovisor/kubectl-trace-bpftrace IMAGE_TRACERUNNER_BRANCH := $(IMAGE_NAME):$(GIT_BRANCH_CLEAN) IMAGE_TRACERUNNER_COMMIT := $(IMAGE_NAME):$(GIT_COMMIT) -IMAGE_TRACERUNNER_LATEST := $(IMAGE_NAME):latest IMAGE_INITCONTAINER_BRANCH := $(IMAGE_NAME_INIT):$(GIT_BRANCH_CLEAN) IMAGE_INITCONTAINER_COMMIT := $(IMAGE_NAME_INIT):$(GIT_COMMIT) IMAGE_INITCONTAINER_LATEST := $(IMAGE_NAME_INIT):latest -BPFTRACESHA ?= aaed58fbb365a21f5a609521b1fc8e53aa67a97f -BCCVERSION ?= 0.8.0 -IMAGE_BPFTRACE_BASE := $(IMAGE_NAME_BASE):$(BPFTRACESHA) - IMAGE_BUILD_FLAGS ?= "--no-cache" +BPFTRACEVERSION ?= "0.9.2-1" + LDFLAGS := -ldflags '-X github.com/iovisor/kubectl-trace/pkg/version.buildTime=$(shell date +%s) -X github.com/iovisor/kubectl-trace/pkg/version.gitCommit=${GIT_COMMIT} -X github.com/iovisor/kubectl-trace/pkg/cmd.ImageNameTag=${IMAGE_TRACERUNNER_COMMIT} -X github.com/iovisor/kubectl-trace/pkg/cmd.InitImageNameTag=${IMAGE_INITCONTAINER_COMMIT}' TESTPACKAGES := $(shell go list ./... | grep -v github.com/iovisor/kubectl-trace/integration) @@ -46,24 +41,25 @@ ${trace_runner}: clean: rm -Rf _output -.PHONY: image/build -image/build: - $(DOCKER) build \ - --build-arg bpftracesha=$(BPFTRACESHA) \ - --build-arg imagenamebase=$(IMAGE_NAME_BASE) \ - $(IMAGE_BUILD_FLAGS) \ - -t $(IMAGE_TRACERUNNER_BRANCH) \ - -f Dockerfile.tracerunner . - $(DOCKER) tag $(IMAGE_TRACERUNNER_BRANCH) $(IMAGE_TRACERUNNER_COMMIT) - .PHONY: image/build-init image/build-init: $(DOCKER) build \ $(IMAGE_BUILD_FLAGS) \ -t $(IMAGE_INITCONTAINER_BRANCH) \ - -f ./init/Dockerfile.initcontainer ./init + -f ./build/Dockerfile.initcontainer ./build $(DOCKER) tag $(IMAGE_INITCONTAINER_BRANCH) $(IMAGE_INITCONTAINER_COMMIT) +.PHONY: image/build +image/build: + $(DOCKER) build \ + --build-arg bpftraceversion=$(BPFTRACEVERSION) \ + $(IMAGE_BUILD_FLAGS) \ + -t "$(IMAGE_TRACERUNNER_BRANCH)" \ + -f build/Dockerfile.tracerunner . + $(DOCKER) tag $(IMAGE_TRACERUNNER_BRANCH) $(IMAGE_TRACERUNNER_COMMIT) + $(DOCKER) tag "$(IMAGE_TRACERUNNER_BRANCH)" $(IMAGE_TRACERUNNER_BRANCH) + + .PHONY: image/push image/push: $(DOCKER) push $(IMAGE_TRACERUNNER_BRANCH) @@ -85,11 +81,3 @@ test: .PHONY: integration integration: TEST_KUBECTLTRACE_BINARY=$(shell pwd)/$(kubectl_trace) $(GO) test ${LDFLAGS} -v ./integration/... - -.PHONY: bpftraceimage/build -bpftraceimage/build: - $(DOCKER) build --build-arg bccversion=$(BCCVERSION) --build-arg bpftracesha=$(BPFTRACESHA) $(IMAGE_BUILD_FLAGS) -t $(IMAGE_BPFTRACE_BASE) -f Dockerfile.bpftracebase . - -.PHONY: bpftraceimage/push -bpftraceimage/push: - $(DOCKER) push $(IMAGE_BPFTRACE_BASE) diff --git a/build/Dockerfile.initcontainer b/build/Dockerfile.initcontainer new file mode 100644 index 00000000..1fdbac24 --- /dev/null +++ b/build/Dockerfile.initcontainer @@ -0,0 +1,15 @@ +FROM alpine:3.8 +RUN apk add --update \ + bash \ + bc \ + build-base \ + curl \ + libelf-dev \ + linux-headers \ + make + +WORKDIR / + +COPY /init/fetch-linux-headers.sh / + +ENTRYPOINT [ "/fetch-linux-headers.sh" ] diff --git a/build/Dockerfile.tracerunner b/build/Dockerfile.tracerunner new file mode 100644 index 00000000..789d91ca --- /dev/null +++ b/build/Dockerfile.tracerunner @@ -0,0 +1,18 @@ +FROM golang:1.11.4-stretch as gobuilder + +RUN apt-get update +RUN apt-get install -y make bash git + +ADD . /go/src/github.com/iovisor/kubectl-trace +WORKDIR /go/src/github.com/iovisor/kubectl-trace + +RUN make _output/bin/trace-runner + +FROM ubuntu:19.10 +ARG bpftraceversion=0.9.2-1 +RUN apt-get update && apt-get install -y bpftrace=${bpftraceversion} && \ + rm -rf /var/lib/apt/lists/* && apt-get clean + +COPY --from=gobuilder /go/src/github.com/iovisor/kubectl-trace/_output/bin/trace-runner /bin/trace-runner + +ENTRYPOINT ["/bin/trace-runner"] diff --git a/init/fetch-linux-headers.sh b/build/init/fetch-linux-headers.sh similarity index 100% rename from init/fetch-linux-headers.sh rename to build/init/fetch-linux-headers.sh diff --git a/init/Dockerfile.initcontainer b/init/Dockerfile.initcontainer deleted file mode 100644 index cc79bbc6..00000000 --- a/init/Dockerfile.initcontainer +++ /dev/null @@ -1,15 +0,0 @@ -FROM alpine:3.8 -RUN apk add --update \ - bash \ - bc \ - build-base \ - curl \ - libelf-dev \ - linux-headers \ - make - -WORKDIR / - -COPY /fetch-linux-headers.sh / - -ENTRYPOINT [ "/fetch-linux-headers.sh" ]