From b5fcbb18e9f0bf91d2733dfb033b9c1bf0f8f865 Mon Sep 17 00:00:00 2001 From: Dale Hamel Date: Mon, 28 Jan 2019 00:29:59 -0500 Subject: [PATCH] Support for ubuntu image in makefile, bump to v0.9 --- Makefile | 45 +++++++------------ .../Dockerfile.bpftracebase-alpine | 0 build/Dockerfile.bpftracebase-ubuntu | 30 +++++++++++++ .../Dockerfile.tracerunner-alpine | 0 build/Dockerfile.tracerunner-ubuntu | 25 +++++++++++ build/sources.list | 8 ++++ 6 files changed, 78 insertions(+), 30 deletions(-) rename Dockerfile.bpftracebase => build/Dockerfile.bpftracebase-alpine (100%) create mode 100644 build/Dockerfile.bpftracebase-ubuntu rename Dockerfile.tracerunner => build/Dockerfile.tracerunner-alpine (100%) create mode 100644 build/Dockerfile.tracerunner-ubuntu create mode 100644 build/sources.list diff --git a/Makefile b/Makefile index 3c7496fc..52682575 100644 --- a/Makefile +++ b/Makefile @@ -8,23 +8,16 @@ 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_NAME_INIT ?= quay.io/iovisor/kubectl-trace-init - -IMAGE_TRACERUNNER_BRANCH := $(IMAGE_NAME):$(GIT_BRANCH_CLEAN) -IMAGE_TRACERUNNER_COMMIT := $(IMAGE_NAME):$(GIT_COMMIT) -IMAGE_TRACERUNNER_LATEST := $(IMAGE_NAME):latest +IMAGE_TRACERUNNER_BRANCH := $(IMAGE_NAME):$(GIT_BRANCH_CLEAN) +IMAGE_TRACERUNNER_COMMIT := $(IMAGE_NAME):$(GIT_COMMIT) 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" 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}' @@ -46,24 +39,24 @@ ${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 \ + $(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 +78,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/Dockerfile.bpftracebase b/build/Dockerfile.bpftracebase-alpine similarity index 100% rename from Dockerfile.bpftracebase rename to build/Dockerfile.bpftracebase-alpine diff --git a/build/Dockerfile.bpftracebase-ubuntu b/build/Dockerfile.bpftracebase-ubuntu new file mode 100644 index 00000000..482aa21f --- /dev/null +++ b/build/Dockerfile.bpftracebase-ubuntu @@ -0,0 +1,30 @@ +FROM ubuntu:18.04 as builder +ARG bpftracesha +ENV RUN_TESTS=0 + +RUN apt-get update && apt-get install -y wget gnupg && apt-get clean + +RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - +COPY build/sources.list /etc/apt/sources.list.d/llvm.list + +RUN wget -O - https://repo.iovisor.org/GPG-KEY | apt-key add - +RUN echo "deb https://repo.iovisor.org/apt/bionic bionic main" > /etc/apt/sources.list.d/iovisor.list + +RUN apt-get update + +RUN apt-get install -y bison cmake flex g++ git libelf-dev zlib1g-dev libfl-dev +RUN apt-get install -y clang-5.0 libclang-5.0-dev libclang-common-5.0-dev libclang1-5.0 libllvm5.0 llvm-5.0 llvm-5.0-dev llvm-5.0-runtime +RUN apt-get install -y libbcc=0.9.0-1 + +ADD https://github.com/iovisor/bpftrace/archive/${bpftracesha}.tar.gz /bpftrace.tar.gz +RUN tar -xvf /bpftrace.tar.gz + +RUN mv bpftrace-${bpftracesha} /bpftrace + +RUN mkdir /bpftrace/build + +WORKDIR /bpftrace/build + +RUN cmake -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_INSTALL_PREFIX=/usr/local/bpftrace .. +RUN make -j9 +RUN make install diff --git a/Dockerfile.tracerunner b/build/Dockerfile.tracerunner-alpine similarity index 100% rename from Dockerfile.tracerunner rename to build/Dockerfile.tracerunner-alpine diff --git a/build/Dockerfile.tracerunner-ubuntu b/build/Dockerfile.tracerunner-ubuntu new file mode 100644 index 00000000..4eb33466 --- /dev/null +++ b/build/Dockerfile.tracerunner-ubuntu @@ -0,0 +1,25 @@ +ARG bpftracesha +ARG imagenamebase + +FROM ${imagenamebase}:${bpftracesha} as bpftrace +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:18.04 + +RUN apt-get update && apt-get install -y wget gnupg && \ + echo "deb https://repo.iovisor.org/apt/bionic bionic main" > /etc/apt/sources.list.d/iovisor.list && \ + wget -O - https://repo.iovisor.org/GPG-KEY | apt-key add - && \ + apt-get update && apt-get install -y libbcc=0.9.0-1 libclang1-5.0 libllvm5.0 && rm -rf /var/lib/apt/lists/* && apt-get clean + +COPY --from=bpftrace /usr/local/bpftrace/bin/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/build/sources.list b/build/sources.list new file mode 100644 index 00000000..847ebcb1 --- /dev/null +++ b/build/sources.list @@ -0,0 +1,8 @@ +deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial main +deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial main +# 5.0 +deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main +deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main +# 6.0 +deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main +deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main