forked from projectcalico/bpftool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.s390x
43 lines (34 loc) · 1.59 KB
/
Dockerfile.s390x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
FROM alpine:3.11 as qemu
ARG QEMU_VERSION=6.1.0-8
ARG QEMU_ARCHS="s390x"
RUN apk --update add curl
# Enable non-native runs on amd64 architecture hosts
RUN curl -L https://github.com/multiarch/qemu-user-static/releases/download/v${QEMU_VERSION}/qemu-${QEMU_ARCHS}-static.tar.gz | tar zxvf - -C /usr/bin &&\
chmod +x /usr/bin/qemu-s390x-static
FROM s390x/debian:buster-slim as bpftool-build
ARG KERNEL_REPO=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
ARG KERNEL_REF=master
COPY --from=qemu /usr/bin/qemu-s390x-static /usr/bin/
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends \
gpg gpg-agent libelf-dev libmnl-dev libc-dev iptables libgcc-8-dev \
bash-completion binutils binutils-dev make git curl \
ca-certificates xz-utils gcc pkg-config bison flex build-essential && \
apt-get purge --auto-remove && \
apt-get clean
WORKDIR /tmp
RUN \
git clone --depth 1 -b $KERNEL_REF $KERNEL_REPO && \
cd linux/tools/bpf/bpftool/ && \
sed -i '/CFLAGS += -O2/a CFLAGS += -static' Makefile && \
sed -i 's/LIBS = -lelf $(LIBBPF)/LIBS = -lelf -lz $(LIBBPF)/g' Makefile && \
printf 'feature-libbfd=0\nfeature-libelf=1\nfeature-bpf=1\nfeature-libelf-mmap=1' >> FEATURES_DUMP.bpftool && \
FEATURES_DUMP=`pwd`/FEATURES_DUMP.bpftool make -j `getconf _NPROCESSORS_ONLN` && \
strip bpftool && \
ldd bpftool 2>&1 | grep -q -e "Not a valid dynamic program" \
-e "not a dynamic executable" || \
( echo "Error: bpftool is not statically linked"; false ) && \
mv bpftool /usr/bin && rm -rf /tmp/linux
FROM scratch
COPY --from=bpftool-build /usr/bin/bpftool /bpftool