-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
73 lines (61 loc) · 2.1 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
FROM debian:bullseye
# Install build dependencies
RUN apt-get update && apt-get install -y \
build-essential \
wget \
bc \
bzip2 \
cpio \
flex \
bison \
libelf-dev \
gcc-i686-linux-gnu \
binutils-i686-linux-gnu \
&& rm -rf /var/lib/apt/lists/*
# Create rootfs
WORKDIR /build
RUN mkdir -p /build/rootfs/bin \
/build/rootfs/dev \
/build/rootfs/proc \
/build/rootfs/sys \
/build/rootfs/etc
# Get and build busybox
RUN wget https://busybox.net/downloads/busybox-1.35.0.tar.bz2 && \
tar xf busybox-1.35.0.tar.bz2 && \
rm busybox-1.35.0.tar.bz2
RUN cd /build/busybox-1.35.0 && \
make defconfig ARCH=i386 CROSS_COMPILE=i686-linux-gnu- && \
sed -i 's/^# CONFIG_STATIC is not set/CONFIG_STATIC=y/' .config && \
sed -i 's/^CONFIG_FEATURE_MOUNT_NFS=y/CONFIG_FEATURE_MOUNT_NFS=n/' .config && \
sed -i 's/^CONFIG_FEATURE_INETD_RPC=y/CONFIG_FEATURE_INETD_RPC=n/' .config && \
make LDFLAGS='-static' ARCH=i386 CROSS_COMPILE=i686-linux-gnu- -j$(nproc) && \
i686-linux-gnu-strip busybox && \
cp busybox /build/rootfs/bin/ && \
cd /build/rootfs/bin && \
chmod +x busybox && \
ln -s busybox sh
# Get and build kernel
RUN wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.15.137.tar.xz && \
tar xf linux-5.15.137.tar.xz && \
rm linux-5.15.137.tar.xz
COPY kernel.config /build/linux-5.15.137/.config
RUN cd /build/linux-5.15.137 && \
make ARCH=i386 CROSS_COMPILE=i686-linux-gnu- oldconfig < /dev/null && \
make ARCH=i386 CROSS_COMPILE=i686-linux-gnu- bzImage -j$(nproc) && \
cp arch/x86/boot/bzImage /build/
# Create network config
RUN echo "nameserver 8.8.8.8" > /build/rootfs/etc/resolv.conf
# Add hostname
RUN echo "wtux" > /build/rootfs/etc/hostname
# Create init
COPY init /build/rootfs/init
RUN chmod +x /build/rootfs/init
# Create initramfs
WORKDIR /build/rootfs
RUN find . | cpio -H newc -o | gzip > /build/initramfs.gz
# Copy outputs
RUN mkdir -p /output && \
mv /build/bzImage /output/ && \
mv /build/initramfs.gz /output/ && \
chmod -R 777 /output
CMD ["/bin/sh", "-c", "cp -f /output/* /output-mount/"]