Skip to content

Commit

Permalink
Add Dockerfile
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroki Shirokura <[email protected]>
  • Loading branch information
slankdev committed Oct 25, 2022
1 parent 71a5b23 commit 80d0954
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
ARG CILIUM_LLVM_IMAGE=quay.io/cilium/cilium-llvm:3408daa17f6490a464dfc746961e28ae31964c66
ARG UBUNTU_IMAGE=docker.io/library/ubuntu:22.04

# STAGE(llvm-dist)
FROM ${CILIUM_LLVM_IMAGE} as llvm-dist

# STAGE(iproute2-dist)
FROM ${UBUNTU_IMAGE} as iproute2-dist
RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y \
vim curl git gcc make flex bison clang-12 libbsd-dev libbfd-dev \
libcap-dev libelf-dev gcc-multilib pkg-config linux-tools-`uname -r`
ARG LIBBPF_VERSION="0.8.0"
ARG IPROUTE2_VERSION="5.18.0"
ADD https://github.com/libbpf/libbpf/archive/refs/tags/v${LIBBPF_VERSION}.tar.gz .
RUN tar xvf v${LIBBPF_VERSION}.tar.gz
RUN cd libbpf-${LIBBPF_VERSION}/src && make install BUILD_STATIC_ONLY=1 && make install_pkgconfig
ADD https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/snapshot/iproute2-${IPROUTE2_VERSION}.tar.gz .
RUN tar xvf iproute2-${IPROUTE2_VERSION}.tar.gz
RUN cd iproute2-${IPROUTE2_VERSION} && ./configure --libbpf_force=on --libbpf_dir=/ && make install

# STAGE(flowctl-dist)
FROM golang:1.17 as flowctl-dist
WORKDIR /opt
COPY ./ ./
RUN CGO_ENABLED=0 go build -o ./bin/flowctl ./cmd/flowctl/main.go

# STAGE(rootfs)
FROM ${UBUNTU_IMAGE} as rootfs
RUN DEBIAN_FRONTEND=noninteractive apt update && apt install -y --no-install-recommends \
curl libelf1 libmnl0 bash-completion iptables ipset kmod ca-certificates \
libelf-dev libbsd-dev jq
COPY ./bpf /usr/include/bpf
COPY --from=llvm-dist /usr/local/bin/clang /usr/local/bin/llc /usr/local/bin/
COPY --from=iproute2-dist /usr/sbin/ip /usr/sbin/ss /usr/sbin/tc /usr/sbin/
COPY --from=flowctl-dist /opt/bin/flowctl /usr/bin/
RUN echo "source /etc/bash_completion" >> /root/.bashrc
RUN echo ". <(flowctl completion bash)" >> /root/.bashrc

# FINAL STAGE
FROM scratch
COPY --from=rootfs / /

0 comments on commit 80d0954

Please sign in to comment.