-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathDockerfile
94 lines (61 loc) · 2.3 KB
/
Dockerfile
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
FROM --platform=$BUILDPLATFORM ghcr.io/cilium/ci-kernels-builder:1727287467 AS configure-vmlinux
ARG KERNEL_VERSION
# Download and cache kernel
COPY download.sh .
RUN --mount=type=cache,target=/tmp/kernel ./download.sh
WORKDIR /usr/src/linux
COPY ccache.conf /etc/ccache.conf
COPY configure-vmlinux.sh env.sh config config-arm64 config-x86_64 .
ARG KBUILD_BUILD_TIMESTAMP="Thu 6 Jul 01:00:00 UTC 2023"
ARG KBUILD_BUILD_HOST="ci-kernels-builder"
ARG TARGETPLATFORM
RUN ./configure-vmlinux.sh
FROM configure-vmlinux AS build-vmlinux
COPY build-vmlinux.sh .
RUN --mount=type=cache,target=/ccache \
ccache -z; \
./build-vmlinux.sh && \
ccache -s
# Install vmlinuz
RUN mkdir -p /tmp/output/boot && \
find ./ -type f -name '*Image' -exec cp -v {} /tmp/output/boot/vmlinuz \;
# Install modules in /usr/lib/modules, with a symlink from /lib to
# /usr/lib. This avoids breaking overlay in merged usr scenarios.
RUN if [ -d tools/testing/selftests/bpf/bpf_testmod ]; then \
make M=tools/testing/selftests/bpf/bpf_testmod INSTALL_MOD_PATH=/tmp/output/usr modules_install; \
ln -s usr/lib /tmp/output/lib; \
fi
FROM build-vmlinux as build-vmlinux-debug
# Package debug info
RUN mkdir -p /tmp/debug/boot
COPY copy-debug.sh filter-debug.awk .
RUN ./copy-debug.sh /tmp/debug
# Build selftests
FROM build-vmlinux as build-selftests
ARG BUILDPLATFORM
RUN if [ "$BUILDPLATFORM" != "$TARGETPLATFORM" ]; then \
echo "Can't cross compile selftests"; exit 1; \
fi
COPY build-selftests.sh .
RUN --mount=type=cache,target=/ccache \
ccache -z; \
./build-selftests.sh && \
ccache -s
COPY copy-selftests.sh .
RUN mkdir /tmp/selftests && ./copy-selftests.sh /tmp/selftests
# Prepare the final kernel image
FROM scratch as vmlinux
LABEL org.opencontainers.image.licenses=GPL-2.0-only
COPY --from=build-vmlinux /tmp/output /
# Debug
FROM vmlinux as vmlinux-debug
LABEL org.opencontainers.image.licenses=GPL-2.0-only
COPY --from=build-vmlinux-debug /tmp/debug /
# Prepare the selftests image
FROM vmlinux as selftests-bpf
LABEL org.opencontainers.image.licenses=GPL-2.0-only
COPY --from=build-selftests /tmp/selftests /usr/src/linux
# Debug
FROM vmlinux-debug as selftests-bpf-debug
LABEL org.opencontainers.image.licenses=GPL-2.0-only
COPY --from=build-selftests /tmp/selftests /usr/src/linux