-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile.linuxbusybox
61 lines (46 loc) · 1.63 KB
/
Dockerfile.linuxbusybox
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
# Dockerfile for building Linux kernel and BusyBox
# Stage 1: Build the Linux kernel and BusyBox
FROM ubuntu:latest AS builder
# Install necessary build dependencies
RUN apt-get update && apt-get install -y \
wget \
build-essential \
libssl-dev \
bc \
flex \
bison \
libelf-dev \
libncurses-dev \
cpio
# Set the working directory
WORKDIR /build
# Check if the Linux kernel source code is already present
RUN [ -f "linux-5.14.tar.xz" ] || wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.14.tar.xz
RUN [ -d "linux-5.14" ] || tar -xf linux-5.14.tar.xz
# Change into the Linux kernel source code directory
WORKDIR /build/linux-5.14
# Build the kernel with tinyconfig
RUN make tinyconfig
RUN make -j$(nproc)
# Set the working directory
WORKDIR /build
# Check if the BusyBox source code is already present
RUN [ -f "busybox-1.34.1.tar.bz2" ] || wget https://busybox.net/downloads/busybox-1.34.1.tar.bz2
RUN [ -d "busybox-1.34.1" ] || tar -xf busybox-1.34.1.tar.bz2
# Change into the BusyBox source code directory
WORKDIR /build/busybox-1.34.1
# Build BusyBox with default configuration
RUN make defconfig
RUN make -j$(nproc)
RUN make install
# Stage 2: Create the bootable disk image
FROM scratch
# Set the necessary environment variables
ENV PATH="/bin"
ENV TERM="xterm"
# Copy the compiled BusyBox binaries from the builder stage
COPY --from=builder /build/busybox-1.34.1/_install/bin/busybox /bin/busybox
# Copy the compiled Linux kernel image from the builder stage
COPY --from=builder /build/linux-5.14/arch/x86/boot/bzImage /boot/vmlinuz
# Set the entrypoint to the BusyBox binary
ENTRYPOINT ["/bin/busybox"]